I have a service named manager
, which sometimes updates itself (from some network location). If something wrong happens during this update, like a system shutdown, I want to replace the bad executable with a known-working one. This resulted in me having two Upstart jobs.
The main job file:
exec /usr/local/bin/manager
start on startup
respawn
The watchdog job file:
start on stopping manager PROCESS="respawn"
script
WATCHED="manager"
EXE="/usr/local/bin/$WATCHED"
cp /usr/local/var/"$WATCHED".bk $EXE
chmod +x $EXE
start $WATCHED
end script
2 questions:
Is this a fine approach... can it be improved?
Is there a way to do all this in just one job file?
manager
job goes down, instead of after n failures (like the title implies). If you're doing that, why not use apost-stop
/pre-start
combo? – muru Nov 13 '14 at 08:02PROCESS="respawn"
does. – tshepang Nov 13 '14 at 08:03PROCESS="respawn"
. Still, why not usepre-start
instead? Something like:pre-start script if [ "$PROCESS" = "respawn" ]; then blah; fi end script
? -- Scratch that. Looking at the cookbook, I think your current way is right. – muru Nov 13 '14 at 08:23pre-start
, would that live in the watchdog job file? – tshepang Nov 13 '14 at 08:38