Details
Description
Please add feature to start cf-execd from init, upstart or systemd with respawn option to make sure that cf-execd is always running.
Example for init
<pre>
ce:2345:respawn:/var/cfengine/bin/cf-execd --no-fork
</pre>
For respawn to work correctly, processes should not fork themselves. The respawn attribute is associated with the parent process that is started, not the forked child processes.
Just looked at the source code of cfengine-3.3.5\src\cf-execd.c
When starting cf-execd with --nofork or -F option ONCE flag is set to true
<pre>
case 'F':
ONCE = true;
NO_FORK = true;
break;
</pre>
So, cf-execd does not start an infinite loop and exit after every execution.
<pre>
if (ONCE)
else
{
while (true)
{
if (ScheduleRun())
{
CfOut(cf_verbose, "", "Sleeping for splaytime %d seconds\n\n", SPLAYTIME);
sleep(SPLAYTIME);
#if defined(HAVE_PTHREAD)
if (!LocalExecInThread(&config))
#endif
}
}
}
<pre>
Of course init restarts the process but it is disrupts the normal cycle of the program. Therefore at the moment it is not possible to use respawn.
Seems like it is possible to make small changes to cf-execd.c to support running from respawn. For example, separate option --once or -O.