Re: [systemd-devel] Query regarding NOTIFY_SOCKET

2016-11-08 Thread Michael Chapman

On Tue, 8 Nov 2016, Raghavendra. H. R wrote:

Does it mean that only services can notify systemd about their readiness
and systemd will not notify another service.


The "notify" in Type=notify has nothing to do with notifications *between* 
units.


The Type= directive's only purpose is to tell systemd what to look for to 
know whether the service has completed startup -- that is, the condition 
which causes the service to transition from an "activating" state to an 
"active" state. Type=notify means "the service has completed startup when 
the service has called sd_notify with READY=1".


If you want one service's startup to cause another service to start, then 
you need some kind of dependency between them. In particular, if you want 
second.service to be automatically started whenever one.service is 
started, then you probably want to set up a Wants= or Requires= 
relationship. See the systemd.unit(5) manpage for details on these 
directives.


Note that it is perfectly fine for one.service to have 
Wants=second.service (that is, "whenever one.service is started, try to 
also start second.service") even though second.service is 
After=one.service (i.e. "whenever one.service and second.service are being 
started together, ensure second.service is only started after one.service 
has reached the 'active' state"). Requirement dependencies 
(Wants/Requires/etc.) and ordering dependencies (After/Before) are largely 
orthogonal.


I should add though if you just want these two services to be started 
together at boot, then the [Install] section you've got there is 
sufficient. When both those services are enabled, the multi-user.target 
will have a Wants= relationship with both the services -- that is, in 
order to start multi-user.target systemd knows it also needs to start 
one.service and second.service.


Hope this clears a few things up.

- Michael
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Query regarding NOTIFY_SOCKET

2016-11-08 Thread Raghavendra. H. R
Does it mean that only services can notify systemd about their readiness
and systemd will not notify another service.

sd_notify call from *Myapp *of one.service is returning value '1'. So
one.service has successfully notified systemd that it is READY.

*But I observe second.service is not starting. I have given
NotifyAccess=all in one.service.*

One.service

*[Unit]*
*Description=one Sd_notify example*
*Before=second.service*

*[Service]*
*Type=notify*
*NotifyAccess=all*
*ExecStart=/etc/Myapp*

*[Install]*
*WantedBy=multi-user.target*


*Second.service*
*=*
*[Unit]*
*Description=Second Sd_notify example*
*After=one.service*

*[Service]*
*ExecStart=/etc/Second_Myapp*

*[Install]*
*WantedBy=multi-user.target*


I dont see second.service starting after sd_notify is done from one.service.


Regards,
Raghavendra H R

--
Regards,

Raghavendra. H. R
(Raghu)

On Tue, Nov 8, 2016 at 7:47 PM, Alessandro Puccetti 
wrote:

> I do not understand the relation between your question and service
> dependencies (e.g. Requires= and After= directives).
>
> Second is started when all the required services are ready, because of
> "Requires=one.service" second will be started after one's status is READY.
> Because one is Type=notify this state is not reached until one executes
> sd_notify(...).
>
>
> On Tue, Nov 8, 2016 at 2:59 PM, Raghavendra. H. R 
> wrote:
>
>> Just one last question.
>> Does systemd notifies other services based on this notification ?
>>
>
> In this case are the services to notify systemd not vice-versa and
> notifications are accepted  by systemd for a specific service the depending
> on the value of Type= and NotifyAccess=.
>
>>
>> I have 2 service files, application in one service file sends
>> notification using sd_notify does systemd starts another service file.
>>
>> one.service
>> 
>> *[Unit]*
>> *Description=Sd_notify example*
>> *Before=second.service*
>>
>> *[Service]*
>> *Type=notify*
>> *ExecStart=/etc/Myapp*
>>
> As I said before you may need to add "NotifyAccess=all" here.
>
>>
>> *[Install]*
>> *WantedBy=multi-user.target*
>>
>> second.service
>> ==
>> *[Unit]*
>> *Description=Second sd_notify example*
>> *Requires=**one.service*
>> *After=one.service*
>>
>> *[Service]*
>> *ExecStart=/etc/SecondApp*
>>
>> *[Install]*
>> *WantedBy=multi-user.target*
>>
>>
>>
>> *Regards,*
>> *Raghavendra H R*
>>
>> --
>> Regards,
>>
>> Raghavendra. H. R
>> (Raghu)
>>
>> On Tue, Nov 8, 2016 at 7:14 PM, Alessandro Puccetti <
>> alessan...@kinvolk.io> wrote:
>>
>>>
>>>
>>> On Tue, Nov 8, 2016 at 2:28 PM, Raghavendra. H. R 
>>> wrote:
>>>
 Hi Tomasz,

 Thanks for pointing out the mistake. I actually missed the line
 "Type=notify" in the mail.
 I found the journalctl logs and from that I can make out the real
 problem is not about NOTIFY_SOCKET. It is about child process in my
 application *Myapp.*

 Below given is my Service file.

 *[Unit]*
 *Description=Sd_notify example*

 *[Service]*
 *Type=notify*
 *ExecStart=/etc/Myapp*

 *[Install]*
 *WantedBy=multi-user.target*

 And in Myapp code my application is using fork() to create a child
 process. Because of which notification is not working correctly.

 This is error log


 *localhost systemd[1]: sd_example.service: Got notification message
 from PID 1270, but reception only permitted for main PID 1106*

 Is there any way from which we can force sd_notify to make use of
 Parent PID instead of child process. My sd_notify is after the fork() call,
 so I doubt sd_notify is called from child process.

 MyApp code snippet

 *int count = 0;*
 *cpid = fork();*

 *if (cpid < 0)*
 *{*
 *printf("vfork failed.");*
 *}*

 *if (cpid == 0)*
 *{*
 *count++;*
 *if(count == 1)*
 * {*

>>> This notificaiton is done by the child process, but notificaitons are
>>> accepted by default only form the main process. Read doc aobut
>>> "NotifyAccess=". https://www.freedesktop.org/software/system
>>> d/man/systemd.service.html#NotifyAccess=
>>>
 * ret = sd_notify(0, "READY=1");*
 * printf("Return value = %d \n");*
 * }*
 * }*


 Regards,
 Raghavendra H R

 --
 Regards,

 Raghavendra. H. R
 (Raghu)

 On Tue, Nov 8, 2016 at 5:15 PM, Tomasz Torcz 
 wrote:

> On Tue, Nov 08, 2016 at 05:01:59PM +0530, Raghavendra. H. R wrote:
> > Hi All,
> >
> > I'm a newbie in Systemd init system and I'm exploring sd_notify
> which is
> > basically used for notification purpose in SystemD.
>
>   It is written “systemd” (all lowercase).
>
> > I have created one unit file which is of type "notify" and 

Re: [systemd-devel] Query regarding NOTIFY_SOCKET

2016-11-08 Thread Alessandro Puccetti
I do not understand the relation between your question and service
dependencies (e.g. Requires= and After= directives).

Second is started when all the required services are ready, because of
"Requires=one.service" second will be started after one's status is READY.
Because one is Type=notify this state is not reached until one executes
sd_notify(...).


On Tue, Nov 8, 2016 at 2:59 PM, Raghavendra. H. R 
wrote:

> Just one last question.
> Does systemd notifies other services based on this notification ?
>

In this case are the services to notify systemd not vice-versa and
notifications are accepted  by systemd for a specific service the depending
on the value of Type= and NotifyAccess=.

>
> I have 2 service files, application in one service file sends notification
> using sd_notify does systemd starts another service file.
>
> one.service
> 
> *[Unit]*
> *Description=Sd_notify example*
> *Before=second.service*
>
> *[Service]*
> *Type=notify*
> *ExecStart=/etc/Myapp*
>
As I said before you may need to add "NotifyAccess=all" here.

>
> *[Install]*
> *WantedBy=multi-user.target*
>
> second.service
> ==
> *[Unit]*
> *Description=Second sd_notify example*
> *Requires=**one.service*
> *After=one.service*
>
> *[Service]*
> *ExecStart=/etc/SecondApp*
>
> *[Install]*
> *WantedBy=multi-user.target*
>
>
>
> *Regards,*
> *Raghavendra H R*
>
> --
> Regards,
>
> Raghavendra. H. R
> (Raghu)
>
> On Tue, Nov 8, 2016 at 7:14 PM, Alessandro Puccetti  > wrote:
>
>>
>>
>> On Tue, Nov 8, 2016 at 2:28 PM, Raghavendra. H. R 
>> wrote:
>>
>>> Hi Tomasz,
>>>
>>> Thanks for pointing out the mistake. I actually missed the line
>>> "Type=notify" in the mail.
>>> I found the journalctl logs and from that I can make out the real
>>> problem is not about NOTIFY_SOCKET. It is about child process in my
>>> application *Myapp.*
>>>
>>> Below given is my Service file.
>>>
>>> *[Unit]*
>>> *Description=Sd_notify example*
>>>
>>> *[Service]*
>>> *Type=notify*
>>> *ExecStart=/etc/Myapp*
>>>
>>> *[Install]*
>>> *WantedBy=multi-user.target*
>>>
>>> And in Myapp code my application is using fork() to create a child
>>> process. Because of which notification is not working correctly.
>>>
>>> This is error log
>>>
>>>
>>> *localhost systemd[1]: sd_example.service: Got notification message from
>>> PID 1270, but reception only permitted for main PID 1106*
>>>
>>> Is there any way from which we can force sd_notify to make use of Parent
>>> PID instead of child process. My sd_notify is after the fork() call, so I
>>> doubt sd_notify is called from child process.
>>>
>>> MyApp code snippet
>>>
>>> *int count = 0;*
>>> *cpid = fork();*
>>>
>>> *if (cpid < 0)*
>>> *{*
>>> *printf("vfork failed.");*
>>> *}*
>>>
>>> *if (cpid == 0)*
>>> *{*
>>> *count++;*
>>> *if(count == 1)*
>>> * {*
>>>
>> This notificaiton is done by the child process, but notificaitons are
>> accepted by default only form the main process. Read doc aobut
>> "NotifyAccess=". https://www.freedesktop.org/software/system
>> d/man/systemd.service.html#NotifyAccess=
>>
>>> * ret = sd_notify(0, "READY=1");*
>>> * printf("Return value = %d \n");*
>>> * }*
>>> * }*
>>>
>>>
>>> Regards,
>>> Raghavendra H R
>>>
>>> --
>>> Regards,
>>>
>>> Raghavendra. H. R
>>> (Raghu)
>>>
>>> On Tue, Nov 8, 2016 at 5:15 PM, Tomasz Torcz 
>>> wrote:
>>>
 On Tue, Nov 08, 2016 at 05:01:59PM +0530, Raghavendra. H. R wrote:
 > Hi All,
 >
 > I'm a newbie in Systemd init system and I'm exploring sd_notify which
 is
 > basically used for notification purpose in SystemD.

   It is written “systemd” (all lowercase).

 > I have created one unit file which is of type "notify" and in my
 > application I have written sd_notify(0, "READY=1"); from which
 SystemD can
 > be notified that my process in totally up and running.
 >
 > Below given is my Service file.
 >
 > *[Unit]*
 > *Description=Sd_notify example*
 >
 > *[Service]*
 > *ExecStart=/etc/Myapp*


   This is not 'unit of type notify'. This is unit of type 'simple'.
 Please read "man systemd.service" and paragraph Type= and choose
 correctly.


 > Need help in understanding what value should be set in the environment
 > varaible NOTIFY_SOCKET.
 > But there's no much information/documentation available on
 NOTIFY_SOCKET.

   NOTIFY_SOCKET is filled-in by systemd and it is available when you
 correctly defined unit type.  If you want to check it's value, you can
 user getenv() inside you program and print the value.
   I think amount of documentation about NOTIFY_SOCKET is enough, if
 you think there's something specific missing, let us know.


 --
 Tomasz Torcz   "Never underestimate the bandwidth of 

Re: [systemd-devel] Query regarding NOTIFY_SOCKET

2016-11-08 Thread Raghavendra. H. R
Just one last question.
Does systemd notifies other services based on this notification ?

I have 2 service files, application in one service file sends notification
using sd_notify does systemd starts another service file.

one.service

*[Unit]*
*Description=Sd_notify example*
*Before=second.service*

*[Service]*
*Type=notify*
*ExecStart=/etc/Myapp*

*[Install]*
*WantedBy=multi-user.target*

second.service
==
*[Unit]*
*Description=Second sd_notify example*
*Requires=**one.service*
*After=one.service*

*[Service]*
*ExecStart=/etc/SecondApp*

*[Install]*
*WantedBy=multi-user.target*



*Regards,*
*Raghavendra H R*

--
Regards,

Raghavendra. H. R
(Raghu)

On Tue, Nov 8, 2016 at 7:14 PM, Alessandro Puccetti 
wrote:

>
>
> On Tue, Nov 8, 2016 at 2:28 PM, Raghavendra. H. R 
> wrote:
>
>> Hi Tomasz,
>>
>> Thanks for pointing out the mistake. I actually missed the line
>> "Type=notify" in the mail.
>> I found the journalctl logs and from that I can make out the real problem
>> is not about NOTIFY_SOCKET. It is about child process in my application
>> *Myapp.*
>>
>> Below given is my Service file.
>>
>> *[Unit]*
>> *Description=Sd_notify example*
>>
>> *[Service]*
>> *Type=notify*
>> *ExecStart=/etc/Myapp*
>>
>> *[Install]*
>> *WantedBy=multi-user.target*
>>
>> And in Myapp code my application is using fork() to create a child
>> process. Because of which notification is not working correctly.
>>
>> This is error log
>>
>>
>> *localhost systemd[1]: sd_example.service: Got notification message from
>> PID 1270, but reception only permitted for main PID 1106*
>>
>> Is there any way from which we can force sd_notify to make use of Parent
>> PID instead of child process. My sd_notify is after the fork() call, so I
>> doubt sd_notify is called from child process.
>>
>> MyApp code snippet
>>
>> *int count = 0;*
>> *cpid = fork();*
>>
>> *if (cpid < 0)*
>> *{*
>> *printf("vfork failed.");*
>> *}*
>>
>> *if (cpid == 0)*
>> *{*
>> *count++;*
>> *if(count == 1)*
>> * {*
>>
> This notificaiton is done by the child process, but notificaitons are
> accepted by default only form the main process. Read doc aobut
> "NotifyAccess=". https://www.freedesktop.org/software/
> systemd/man/systemd.service.html#NotifyAccess=
>
>> * ret = sd_notify(0, "READY=1");*
>> * printf("Return value = %d \n");*
>> * }*
>> * }*
>>
>>
>> Regards,
>> Raghavendra H R
>>
>> --
>> Regards,
>>
>> Raghavendra. H. R
>> (Raghu)
>>
>> On Tue, Nov 8, 2016 at 5:15 PM, Tomasz Torcz 
>> wrote:
>>
>>> On Tue, Nov 08, 2016 at 05:01:59PM +0530, Raghavendra. H. R wrote:
>>> > Hi All,
>>> >
>>> > I'm a newbie in Systemd init system and I'm exploring sd_notify which
>>> is
>>> > basically used for notification purpose in SystemD.
>>>
>>>   It is written “systemd” (all lowercase).
>>>
>>> > I have created one unit file which is of type "notify" and in my
>>> > application I have written sd_notify(0, "READY=1"); from which SystemD
>>> can
>>> > be notified that my process in totally up and running.
>>> >
>>> > Below given is my Service file.
>>> >
>>> > *[Unit]*
>>> > *Description=Sd_notify example*
>>> >
>>> > *[Service]*
>>> > *ExecStart=/etc/Myapp*
>>>
>>>
>>>   This is not 'unit of type notify'. This is unit of type 'simple'.
>>> Please read "man systemd.service" and paragraph Type= and choose
>>> correctly.
>>>
>>>
>>> > Need help in understanding what value should be set in the environment
>>> > varaible NOTIFY_SOCKET.
>>> > But there's no much information/documentation available on
>>> NOTIFY_SOCKET.
>>>
>>>   NOTIFY_SOCKET is filled-in by systemd and it is available when you
>>> correctly defined unit type.  If you want to check it's value, you can
>>> user getenv() inside you program and print the value.
>>>   I think amount of documentation about NOTIFY_SOCKET is enough, if
>>> you think there's something specific missing, let us know.
>>>
>>>
>>> --
>>> Tomasz Torcz   "Never underestimate the bandwidth of a
>>> station
>>> xmpp: zdzich...@chrome.plwagon filled with backup tapes." -- Jim
>>> Gray
>>>
>>> ___
>>> systemd-devel mailing list
>>> systemd-devel@lists.freedesktop.org
>>> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>>>
>>
>>
>> ___
>> systemd-devel mailing list
>> systemd-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>>
>>
>
>
> --
>
> Alessandro Puccetti
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Query regarding NOTIFY_SOCKET

2016-11-08 Thread Michael Biebl
I suggest reading https://www.freedesktop.org/software/systemd/man/daemon.html

It's not necessary to fork for a new-style daemon and actually discouraged.

2016-11-08 14:28 GMT+01:00 Raghavendra. H. R :
> Hi Tomasz,
>
> Thanks for pointing out the mistake. I actually missed the line
> "Type=notify" in the mail.
> I found the journalctl logs and from that I can make out the real problem is
> not about NOTIFY_SOCKET. It is about child process in my application Myapp.
>
> Below given is my Service file.
>
> [Unit]
> Description=Sd_notify example
>
> [Service]
> Type=notify
> ExecStart=/etc/Myapp
>
> [Install]
> WantedBy=multi-user.target
>
> And in Myapp code my application is using fork() to create a child process.
> Because of which notification is not working correctly.
>
> This is error log
>
> localhost systemd[1]: sd_example.service: Got notification message from PID
> 1270, but reception only permitted for main PID 1106
>
> Is there any way from which we can force sd_notify to make use of Parent PID
> instead of child process. My sd_notify is after the fork() call, so I doubt
> sd_notify is called from child process.
>
> MyApp code snippet
>
> int count = 0;
> cpid = fork();
>
> if (cpid < 0)
> {
> printf("vfork failed.");
> }
>
> if (cpid == 0)
> {
> count++;
> if(count == 1)
> {
> ret = sd_notify(0, "READY=1");
> printf("Return value = %d \n");
> }
> }
>
>
> Regards,
> Raghavendra H R
>
> --
> Regards,
>
> Raghavendra. H. R
> (Raghu)
>
> On Tue, Nov 8, 2016 at 5:15 PM, Tomasz Torcz  wrote:
>>
>> On Tue, Nov 08, 2016 at 05:01:59PM +0530, Raghavendra. H. R wrote:
>> > Hi All,
>> >
>> > I'm a newbie in Systemd init system and I'm exploring sd_notify which is
>> > basically used for notification purpose in SystemD.
>>
>>   It is written “systemd” (all lowercase).
>>
>> > I have created one unit file which is of type "notify" and in my
>> > application I have written sd_notify(0, "READY=1"); from which SystemD
>> > can
>> > be notified that my process in totally up and running.
>> >
>> > Below given is my Service file.
>> >
>> > *[Unit]*
>> > *Description=Sd_notify example*
>> >
>> > *[Service]*
>> > *ExecStart=/etc/Myapp*
>>
>>
>>   This is not 'unit of type notify'. This is unit of type 'simple'.
>> Please read "man systemd.service" and paragraph Type= and choose
>> correctly.
>>
>>
>> > Need help in understanding what value should be set in the environment
>> > varaible NOTIFY_SOCKET.
>> > But there's no much information/documentation available on
>> > NOTIFY_SOCKET.
>>
>>   NOTIFY_SOCKET is filled-in by systemd and it is available when you
>> correctly defined unit type.  If you want to check it's value, you can
>> user getenv() inside you program and print the value.
>>   I think amount of documentation about NOTIFY_SOCKET is enough, if
>> you think there's something specific missing, let us know.
>>
>>
>> --
>> Tomasz Torcz   "Never underestimate the bandwidth of a station
>> xmpp: zdzich...@chrome.plwagon filled with backup tapes." -- Jim Gray
>>
>> ___
>> systemd-devel mailing list
>> systemd-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
>
>
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>



-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Query regarding NOTIFY_SOCKET

2016-11-08 Thread Alessandro Puccetti
On Tue, Nov 8, 2016 at 2:28 PM, Raghavendra. H. R 
wrote:

> Hi Tomasz,
>
> Thanks for pointing out the mistake. I actually missed the line
> "Type=notify" in the mail.
> I found the journalctl logs and from that I can make out the real problem
> is not about NOTIFY_SOCKET. It is about child process in my application
> *Myapp.*
>
> Below given is my Service file.
>
> *[Unit]*
> *Description=Sd_notify example*
>
> *[Service]*
> *Type=notify*
> *ExecStart=/etc/Myapp*
>
> *[Install]*
> *WantedBy=multi-user.target*
>
> And in Myapp code my application is using fork() to create a child
> process. Because of which notification is not working correctly.
>
> This is error log
>
>
> *localhost systemd[1]: sd_example.service: Got notification message from
> PID 1270, but reception only permitted for main PID 1106*
>
> Is there any way from which we can force sd_notify to make use of Parent
> PID instead of child process. My sd_notify is after the fork() call, so I
> doubt sd_notify is called from child process.
>
> MyApp code snippet
>
> *int count = 0;*
> *cpid = fork();*
>
> *if (cpid < 0)*
> *{*
> *printf("vfork failed.");*
> *}*
>
> *if (cpid == 0)*
> *{*
> *count++;*
> *if(count == 1)*
> * {*
>
This notificaiton is done by the child process, but notificaitons are
accepted by default only form the main process. Read doc aobut
"NotifyAccess=".
https://www.freedesktop.org/software/systemd/man/systemd.service.html#NotifyAccess=

> * ret = sd_notify(0, "READY=1");*
> * printf("Return value = %d \n");*
> * }*
> * }*
>
>
> Regards,
> Raghavendra H R
>
> --
> Regards,
>
> Raghavendra. H. R
> (Raghu)
>
> On Tue, Nov 8, 2016 at 5:15 PM, Tomasz Torcz  wrote:
>
>> On Tue, Nov 08, 2016 at 05:01:59PM +0530, Raghavendra. H. R wrote:
>> > Hi All,
>> >
>> > I'm a newbie in Systemd init system and I'm exploring sd_notify which is
>> > basically used for notification purpose in SystemD.
>>
>>   It is written “systemd” (all lowercase).
>>
>> > I have created one unit file which is of type "notify" and in my
>> > application I have written sd_notify(0, "READY=1"); from which SystemD
>> can
>> > be notified that my process in totally up and running.
>> >
>> > Below given is my Service file.
>> >
>> > *[Unit]*
>> > *Description=Sd_notify example*
>> >
>> > *[Service]*
>> > *ExecStart=/etc/Myapp*
>>
>>
>>   This is not 'unit of type notify'. This is unit of type 'simple'.
>> Please read "man systemd.service" and paragraph Type= and choose
>> correctly.
>>
>>
>> > Need help in understanding what value should be set in the environment
>> > varaible NOTIFY_SOCKET.
>> > But there's no much information/documentation available on
>> NOTIFY_SOCKET.
>>
>>   NOTIFY_SOCKET is filled-in by systemd and it is available when you
>> correctly defined unit type.  If you want to check it's value, you can
>> user getenv() inside you program and print the value.
>>   I think amount of documentation about NOTIFY_SOCKET is enough, if
>> you think there's something specific missing, let us know.
>>
>>
>> --
>> Tomasz Torcz   "Never underestimate the bandwidth of a station
>> xmpp: zdzich...@chrome.plwagon filled with backup tapes." -- Jim Gray
>>
>> ___
>> systemd-devel mailing list
>> systemd-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>>
>
>
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
>


-- 

Alessandro Puccetti
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Query regarding NOTIFY_SOCKET

2016-11-08 Thread Raghavendra. H. R
Hi Tomasz,

Thanks for pointing out the mistake. I actually missed the line
"Type=notify" in the mail.
I found the journalctl logs and from that I can make out the real problem
is not about NOTIFY_SOCKET. It is about child process in my application
*Myapp.*

Below given is my Service file.

*[Unit]*
*Description=Sd_notify example*

*[Service]*
*Type=notify*
*ExecStart=/etc/Myapp*

*[Install]*
*WantedBy=multi-user.target*

And in Myapp code my application is using fork() to create a child process.
Because of which notification is not working correctly.

This is error log


*localhost systemd[1]: sd_example.service: Got notification message from
PID 1270, but reception only permitted for main PID 1106*

Is there any way from which we can force sd_notify to make use of Parent
PID instead of child process. My sd_notify is after the fork() call, so I
doubt sd_notify is called from child process.

MyApp code snippet

*int count = 0;*
*cpid = fork();*

*if (cpid < 0)*
*{*
*printf("vfork failed.");*
*}*

*if (cpid == 0)*
*{*
*count++;*
*if(count == 1)*
* {*
* ret = sd_notify(0, "READY=1");*
* printf("Return value = %d \n");*
* }*
* }*


Regards,
Raghavendra H R

--
Regards,

Raghavendra. H. R
(Raghu)

On Tue, Nov 8, 2016 at 5:15 PM, Tomasz Torcz  wrote:

> On Tue, Nov 08, 2016 at 05:01:59PM +0530, Raghavendra. H. R wrote:
> > Hi All,
> >
> > I'm a newbie in Systemd init system and I'm exploring sd_notify which is
> > basically used for notification purpose in SystemD.
>
>   It is written “systemd” (all lowercase).
>
> > I have created one unit file which is of type "notify" and in my
> > application I have written sd_notify(0, "READY=1"); from which SystemD
> can
> > be notified that my process in totally up and running.
> >
> > Below given is my Service file.
> >
> > *[Unit]*
> > *Description=Sd_notify example*
> >
> > *[Service]*
> > *ExecStart=/etc/Myapp*
>
>
>   This is not 'unit of type notify'. This is unit of type 'simple'.
> Please read "man systemd.service" and paragraph Type= and choose
> correctly.
>
>
> > Need help in understanding what value should be set in the environment
> > varaible NOTIFY_SOCKET.
> > But there's no much information/documentation available on NOTIFY_SOCKET.
>
>   NOTIFY_SOCKET is filled-in by systemd and it is available when you
> correctly defined unit type.  If you want to check it's value, you can
> user getenv() inside you program and print the value.
>   I think amount of documentation about NOTIFY_SOCKET is enough, if
> you think there's something specific missing, let us know.
>
>
> --
> Tomasz Torcz   "Never underestimate the bandwidth of a station
> xmpp: zdzich...@chrome.plwagon filled with backup tapes." -- Jim Gray
>
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Query regarding NOTIFY_SOCKET

2016-11-08 Thread Tomasz Torcz
On Tue, Nov 08, 2016 at 05:01:59PM +0530, Raghavendra. H. R wrote:
> Hi All,
> 
> I'm a newbie in Systemd init system and I'm exploring sd_notify which is
> basically used for notification purpose in SystemD.

  It is written “systemd” (all lowercase).
 
> I have created one unit file which is of type "notify" and in my
> application I have written sd_notify(0, "READY=1"); from which SystemD can
> be notified that my process in totally up and running.
> 
> Below given is my Service file.
> 
> *[Unit]*
> *Description=Sd_notify example*
> 
> *[Service]*
> *ExecStart=/etc/Myapp*


  This is not 'unit of type notify'. This is unit of type 'simple'.
Please read "man systemd.service" and paragraph Type= and choose
correctly.


> Need help in understanding what value should be set in the environment
> varaible NOTIFY_SOCKET.
> But there's no much information/documentation available on NOTIFY_SOCKET.

  NOTIFY_SOCKET is filled-in by systemd and it is available when you 
correctly defined unit type.  If you want to check it's value, you can
user getenv() inside you program and print the value.
  I think amount of documentation about NOTIFY_SOCKET is enough, if
you think there's something specific missing, let us know.


-- 
Tomasz Torcz   "Never underestimate the bandwidth of a station
xmpp: zdzich...@chrome.plwagon filled with backup tapes." -- Jim Gray

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel