[Unit]
Description=CFEngine Execution Scheduler
After=syslog.target
ConditionPathExists=/var/cfengine/bin/cf-execd
ConditionPathExists=/var/cfengine/inputs/promises.cf
PartOf=cfengine3.service

[Service]
Type=simple
ExecStart=/var/cfengine/bin/cf-execd --no-fork
Restart=always
RestartSec=10
KillMode=process

# Drain in-flight cf-agent, so it does not pull dependencies back in after the
# stop is reported successful (as seen in ENT-14108).
ExecStopPost=/bin/sh -c 't=60; while [ $$t -gt 0 ] && pgrep -x cf-agent >/dev/null 2>&1; do sleep 1; t=$$((t - 1)); done; pkill -KILL -x cf-agent >/dev/null 2>&1 || true'

[Install]
WantedBy=multi-user.target
