* Handle jobs that fail while a post-start script is waiting for them.
svn path=/nixos/trunk/; revision=33269
This commit is contained in:
parent
31c93522d5
commit
fcc2e985a2
@ -102,6 +102,17 @@ initctl emit config-changed
|
|||||||
declare -A tasks=(@tasks@)
|
declare -A tasks=(@tasks@)
|
||||||
declare -A noRestartIfChanged=(@noRestartIfChanged@)
|
declare -A noRestartIfChanged=(@noRestartIfChanged@)
|
||||||
|
|
||||||
|
start_() {
|
||||||
|
local job="$1"
|
||||||
|
if start --quiet "$job"; then
|
||||||
|
# Handle services that cancel themselves.
|
||||||
|
if ! [ -n "${tasks[$job]}" ]; then
|
||||||
|
local status=$(status "$job")
|
||||||
|
[[ "$status" =~ start/running ]] || echo "job ‘$job’ failed to start!"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Restart all running jobs that have changed. (Here "running" means
|
# Restart all running jobs that have changed. (Here "running" means
|
||||||
# all jobs that don't have a "stop" goal.) We use the symlinks in
|
# all jobs that don't have a "stop" goal.) We use the symlinks in
|
||||||
# /var/run/upstart-jobs (created by each job's pre-start script) to
|
# /var/run/upstart-jobs (created by each job's pre-start script) to
|
||||||
@ -118,7 +129,7 @@ for job in @jobs@; do
|
|||||||
# Note: can't use "restart" here, since that only restarts the
|
# Note: can't use "restart" here, since that only restarts the
|
||||||
# job's main process.
|
# job's main process.
|
||||||
stop --quiet "$job" || true
|
stop --quiet "$job" || true
|
||||||
start --quiet "$job" || true
|
start_ "$job" || true
|
||||||
done
|
done
|
||||||
|
|
||||||
# Start all jobs that are not running but should be. The "should be"
|
# Start all jobs that are not running but should be. The "should be"
|
||||||
@ -141,7 +152,7 @@ for job in @jobs@; do
|
|||||||
else
|
else
|
||||||
if ! grep -q "^start on" "$jobsDir/$job.conf"; then continue; fi
|
if ! grep -q "^start on" "$jobsDir/$job.conf"; then continue; fi
|
||||||
echo "starting service ‘$job’..."
|
echo "starting service ‘$job’..."
|
||||||
start --quiet "$job" || true
|
start_ "$job" || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
@ -175,10 +175,16 @@ let
|
|||||||
# Check whether the current job has been stopped. Used in
|
# Check whether the current job has been stopped. Used in
|
||||||
# post-start jobs to determine if they should continue.
|
# post-start jobs to determine if they should continue.
|
||||||
stop_check() {
|
stop_check() {
|
||||||
if [[ "$(status)" =~ stop/ ]]; then
|
local status="$(status)"
|
||||||
|
if [[ "$status" =~ stop/ ]]; then
|
||||||
echo "job asked to stop!"
|
echo "job asked to stop!"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
if [[ "$status" =~ respawn/ ]]; then
|
||||||
|
echo "job respawning unexpectedly!"
|
||||||
|
stop
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user