* Ignore SIGHUP and write errors on stderr to ensure that

switch-to-configuration runs to completion (e.g. if the tty we're on
  got killed).

svn path=/nixos/trunk/; revision=33382
This commit is contained in:
Eelco Dolstra 2012-03-23 13:37:22 +00:00
parent 1949a85987
commit 43b5ced96c

View File

@ -76,6 +76,10 @@ EOF
exit 1 exit 1
fi fi
# Ignore SIGHUP so that we're not killed if we're running on (say)
# virtual console 1 and we restart the "tty1" job.
trap "" SIGHUP
jobsDir=$(readlink -f @out@/etc/init) jobsDir=$(readlink -f @out@/etc/init)
# Stop all currently running jobs that are not in the new Upstart # Stop all currently running jobs that are not in the new Upstart
@ -113,6 +117,10 @@ start_() {
fi fi
} }
log() {
echo "$@" >&2 || true
}
# 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
@ -122,10 +130,10 @@ for job in @jobs@; do
if ! [[ "$status" =~ start/ ]]; then continue; fi if ! [[ "$status" =~ start/ ]]; then continue; fi
if [ "$(readlink -f "$jobsDir/$job.conf")" = "$(readlink -f "/var/run/upstart-jobs/$job")" ]; then continue; fi if [ "$(readlink -f "$jobsDir/$job.conf")" = "$(readlink -f "/var/run/upstart-jobs/$job")" ]; then continue; fi
if [ -n "${noRestartIfChanged[$job]}" ]; then if [ -n "${noRestartIfChanged[$job]}" ]; then
echo "not restarting changed service $job" log "not restarting changed service $job"
continue continue
fi fi
echo "restarting changed service $job..." log "restarting changed service $job..."
# 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
@ -147,11 +155,11 @@ for job in @jobs@; do
"$(readlink -f "$jobsDir/$job.conf")" = "$(readlink -f "/var/run/upstart-jobs/$job")" ]; "$(readlink -f "$jobsDir/$job.conf")" = "$(readlink -f "/var/run/upstart-jobs/$job")" ];
then continue; fi then continue; fi
if [ -n "${noRestartIfChanged[$job]}" ]; then continue; fi if [ -n "${noRestartIfChanged[$job]}" ]; then continue; fi
echo "starting task $job..." log "starting task $job..."
start --quiet "$job" || true start --quiet "$job" || true
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..." log "starting service $job..."
start_ "$job" || true start_ "$job" || true
fi fi