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
Is this a fine approach... can it be improved?
Is there a way to do all this in just one job file?