* Make all Upstart jobs shut down on the `starting shutdown' event.

This ensures that they're gone by the time the shutdown job runs, so
  it doesn't have to stop them itself.
* Don't respawn tasks, as it doesn't seem useful (if they fail they're
  likely to fail again if they're restarted).

svn path=/nixos/trunk/; revision=22099
This commit is contained in:
Eelco Dolstra 2010-06-02 16:04:08 +00:00
parent b135e38bea
commit ad93acc295
3 changed files with 15 additions and 20 deletions

View File

@ -14,9 +14,9 @@ with pkgs.lib;
script =
''
case "$RUNLEVEL" in
0) initctl start shutdown MODE=poweroff;;
1) initctl start shutdown MODE=maintenance;;
6) initctl start shutdown MODE=reboot;;
0) initctl start shutdown --no-wait MODE=poweroff;;
1) initctl start shutdown --no-wait MODE=maintenance;;
6) initctl start shutdown --no-wait MODE=reboot;;
*) echo "Unsupported runlevel: $RUNLEVEL";;
esac
'';

View File

@ -9,8 +9,12 @@ with pkgs.lib;
task = true;
stopOn = ""; # must override the default ("starting shutdown")
environment = { MODE = "poweroff"; };
extraConfig = "console owner";
script =
''
set +e # continue in case of errors
@ -29,24 +33,10 @@ with pkgs.lib;
export PATH=${pkgs.utillinux}/bin:${pkgs.utillinux}/sbin:$PATH
# Set the hardware clock to the system time.
echo "setting the hardware clock..."
hwclock --systohc --utc
# Do an initial sync just in case.
sync
# Stop all Upstart jobs.
initctl list | while IFS=", " read jobName status rest; do
if test "$jobName" != shutdown -a "$status" != "stop/waiting"; then
echo "stopping $jobName..."
stop "$jobName"
fi
done
# Kill all remaining processes except init and this one.
echo "sending the TERM signal to all processes..."
kill -TERM -1
@ -64,12 +54,17 @@ with pkgs.lib;
echo ""
echo "<<< Maintenance shell >>>"
echo ""
while ! ${pkgs.bash}/bin/bash --login; do true; done
${pkgs.pam_login}/bin/login root
initctl emit -n startup
exit 0
fi
# Set the hardware clock to the system time.
echo "setting the hardware clock..."
hwclock --systohc --utc
# Unmount helper functions.
getMountPoints() {
cat /proc/mounts \

View File

@ -75,7 +75,7 @@ let
''}
${optionalString job.task "task"}
${optionalString job.respawn "respawn"}
${optionalString (!job.task && job.respawn) "respawn"}
${optionalString (job.preStop != "") ''
pre-stop script
@ -153,7 +153,7 @@ let
stopOn = mkOption {
type = types.string;
default = "shutdown";
default = "starting shutdown";
description = ''
The Upstart event that triggers this job to be stopped.
'';