> On 2018-05-15, at 21:40, Rainer Müller <[email protected]> wrote:
> 
> On 2018-05-15 20:57, [email protected] wrote:
>> 
>>> On 2018-05-15, at 03:56, Ryan Schmidt <[email protected]> wrote:
>>> 
>>> 
>>> On May 14, 2018, at 11:13, [email protected] wrote:
>>> 
>>>> The Guide states “Executable” StartupItems are preferred over “script” 
>>>> StartupItems. 
>>>> 
>>>> I have 2 daemons that are Perl scripts, they can run "executable", but the 
>>>> previous version of the port used a "script".
>>>> Any reason not to change that?
>>> 
>>> Yes, executables are preferred. That way, launchd can monitor their 
>>> lifetime.
>>> 
>>> Can you elaborate on what your portfiles were doing before? There may be 
>>> reasons why they weren't using executables directly, but without seeing how 
>>> they were set up, it's impossible to say.
>> 
>> Portfile munin @1.4.7:
>> ---
>> startupitem.create  yes
>> startupitem.name    munin-node
>> startupitem.start   "${prefix}/sbin/munin-node"
>> startupitem.stop    "kill `cat ${prefix}/var/run/munin/munin-node.pid`"
>> ---
>> 
>> /opt/local/sbin/munin-node is a perl program. I see see no reason for 
>> daemondo here. launchd KeepAlive would only keep daemondo alive, not the 
>> executed munin-node.
> 
> The generated startupitems will always make use of daemondo. The purpose
> is to turn signals received from launchd into the appropriate action for
> the daemon process.

I know.

> It looks like munin-node will fork itself into the background by
> default. This is incompatible with launchd, as it would assume the
> process died as soon as you launch it. Unless there is a switch or
> configuration option to force it to run as a foreground process, you
> need to use "script" instead of "executable".

No, munin-node doesn't fork itself into the background. It does fork for 
sub-processes. 
Also, I'm running munin node as executable from launchd and it works fine.

> However, I would let daemondo handle the stop command by telling it
> where to find the pidfile written by the daemon:
> 
> startupitem.create  yes
> startupitem.name    munin-node
> startupitem.start   ${prefix}/sbin/munin-node
> startupitem.pidfile clean ${prefix}/var/run/munin/munin-node.pid
> startupitem.netchange yes

That is the way it was done.

> As the munin-node daemon opens a TCP server socket, the port should also
> use startupitem.netchange to ensure the daemon is restarted when the
> network changes in order to bind to the new interface address.

I don't know how to do that in a launchd plist, but since munin-node acts on 
request only, I think it is not a terrible waste to let it run when the network 
goes down.

> Rainer

paul.

Reply via email to