Forum: CFEngine Help
Subject: Re: Starting cf-execd from inittab
Author: aleksey_c
Link to topic: https://cfengine.com/forum/read.php?3,27509,27513#msg-27513
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
case 'F':
ONCE = true;
NO_FORK = true;
break;
So, cf-execd does not start an infinite loop and exit after every execution.
if (ONCE)
{
CfOut(cf_verbose, "", "Sleeping for splaytime %d seconds\n\n",
SPLAYTIME);
sleep(SPLAYTIME);
LocalExec(&config);
CloseLog();
}
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))
{
CfOut(cf_inform, "", "Unable to run agent in thread,
falling back to blocking execution");
#endif
LocalExec(&config);
#if defined(HAVE_PTHREAD)
}
#endif
}
}
}
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 init respawn :(
Seems like it is possible to make small changes to the code of cf-execd.c to
support running from init. For example, separate option --once or -O.
Can I request a feature?
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine