Exit status not propagated with respawn flag

Asked by Jordan Parker

I have a simple upstart task that looks for stopping jobs and reports all of the environ info about them:

crash-reporter.conf:
============================================================
description "Checks for job failure and reports crashes"

# Obviously, we don't need to have this checking itself constantly...
start on stopping JOB!=crash-reporter

task
console log

script
 date
 echo "Job has stopped"
 env
 echo
end script
============================================================

Now, I have a very simple test case job that shows my issue:

failure-job.conf:
============================================================
console log
# No respawn flag here!
script
        sleep 10
        false
end script
============================================================

When I run failure-job (start failure-job), it behaves as expected and I get this:

/var/log/upstart/crash-reporter.log:
============================================================
Tue Aug 14 11:44:03 PDT 2012
Job has stopped
UPSTART_INSTANCE=
EXIT_STATUS=1
INSTANCE=
UPSTART_JOB=crash-reporter
TERM=linux
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
PROCESS=main
UPSTART_EVENTS=stopping
PWD=/
RESULT=failed
JOB=failure-job
============================================================

Looks good! failure-job failed and EXIT_STATUS is 1 as expected. However, if I add the respawn flag to failure-jobs conf, I get this instead:

/var/log/upstart/crash-reporter.log:
============================================================
Tue Aug 14 11:43:41 PDT 2012
Job has stopped
UPSTART_INSTANCE=
INSTANCE=
UPSTART_JOB=crash-reporter
TERM=linux
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
UPSTART_EVENTS=stopping
PWD=/
RESULT=ok
JOB=failure-job
============================================================

Note that RESULT is 'ok' and there's no exit status reported (which seems normal for result = ok).
What I expect to happen: When a job is set to respawn, if the exit status is non-zero, this is reported in the 'stopping' event as it is when a job is set to not respawn.

Is this intended upstart behavior?

Question information

Language:
English Edit question
Status:
Expired
For:
upstart Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Jordan Parker (nepthar) said :
#1

Current workaround:

- Do NOT have the respawn flag set in the service job
- Have the crash reporter restart the service job manually

xxx-crash-reporter.conf:
============================================================
description "Detect and report crashes"
start on stopped RESULT=failed JOB!=xxx-crash-reporter

task
console log

script
 case $JOB in
  # Check if the job begins with our prefix.
  xxx-*)
   # Perform some checking and notification stuff here
   # For example, examine the log file found at /var/log/upstart/${JOB}.log
   # .. Now restart the job.
   initctl start ${JOB} || true
   ;;
  *)
   ;;
 esac

end script
============================================================

Shortcomings:
- Can't emulate the respawn limit stanza
- Not as cool!

Revision history for this message
Launchpad Janitor (janitor) said :
#2

This question was expired because it remained in the 'Open' state without activity for the last 15 days.