1

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?

tshepang
  • 65,642
  • First thing that pops out is this: You're replacing the binary whenever the manager job goes down, instead of after n failures (like the title implies). If you're doing that, why not use a post-stop/pre-start combo? – muru Nov 13 '14 at 08:02
  • No, it only gets replaced after n failures. Thats what PROCESS="respawn" does. – tshepang Nov 13 '14 at 08:03
  • Ah, didn't know about PROCESS="respawn". Still, why not use pre-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:23
  • Am curious: if I were to use pre-start, would that live in the watchdog job file? – tshepang Nov 13 '14 at 08:38

0 Answers0