Exit status not propagated with respawn flag
I have a simple upstart task that looks for stopping jobs and reports all of the environ info about them:
crash-reporter.
=======
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/
=======
Tue Aug 14 11:44:03 PDT 2012
Job has stopped
UPSTART_INSTANCE=
EXIT_STATUS=1
INSTANCE=
UPSTART_
TERM=linux
PATH=/usr/
PROCESS=main
UPSTART_
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/
=======
Tue Aug 14 11:43:41 PDT 2012
Job has stopped
UPSTART_INSTANCE=
INSTANCE=
UPSTART_
TERM=linux
PATH=/usr/
UPSTART_
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:
- 2012-08-14
- Last reply:
- 2012-09-01
| 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-
=======
description "Detect and report crashes"
start on stopped RESULT=failed JOB!=xxx-
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/
# .. Now restart the job.
initctl start ${JOB} || true
;;
*)
;;
esac
end script
=======
Shortcomings:
- Can't emulate the respawn limit stanza
- Not as cool!
| Launchpad Janitor (janitor) said : | #2 |
This question was expired because it remained in the 'Open' state without activity for the last 15 days.

