* Allow Upstart jobs to declare that they shouldn't be restarted by

switch-to-configuration.  E.g. the X server shouldn't be restarted
  because that kills all the X clients.

svn path=/nixos/trunk/; revision=33223
This commit is contained in:
Eelco Dolstra 2012-03-18 02:10:39 +00:00
parent 3495a773f9
commit 86d8d62d16
6 changed files with 22 additions and 10 deletions

View File

@ -126,6 +126,8 @@ in
+ optionalString config.services.tomcat.enable " and started tomcat"
+ optionalString config.services.svnserve.enable " and started svnserve";
restartIfChanged = false;
script =
''
export PATH=/var/run/current-system/sw/bin:/var/run/current-system/sw/sbin

View File

@ -118,6 +118,8 @@ in
jobs.dbus =
{ startOn = "started udev and started syslogd";
restartIfChanged = false;
path = [ pkgs.dbus_daemon pkgs.dbus_tools ];
preStart =

View File

@ -392,7 +392,9 @@ in
};
jobs.xserver =
{ environment =
{ restartIfChanged = false;
environment =
{ FONTCONFIG_FILE = "/etc/fonts/fonts.conf"; # !!! cleanup
XKB_BINDIR = "${xorg.xkbcomp}/bin"; # Needed for the Xkb extension.
TZ = config.time.timeZone;

View File

@ -108,14 +108,7 @@ for job in $(cd $newJobs && ls *.conf); do
status=$(status "$job")
if ! [[ "$status" =~ start/ ]]; then continue; fi
if [ "$(readlink -f "$newJobs/$job.conf")" = "$(readlink -f "/var/run/upstart-jobs/$job")" ]; then continue; fi
# Hack: don't restart the X server (that would kill all the clients).
# And don't restart dbus, since that causes ConsoleKit to
# forget about current sessions.
# Idem for xendomains because we don't want to save/restore
# Xen domains unless we have to.
# TODO: Jobs should be able to declare that they should not be
# auto-restarted.
if echo "$job" | grep -q "^xserver$\|^dbus$\|^disnix$\|^xendomains$\|^udevtrigger$"; then
if ! grep -q "^# RESTART-IF-CHANGED" "$newJobs/$job.conf"; then
echo "not restarting changed service $job"
continue
fi

View File

@ -82,6 +82,8 @@ let
${optionalString job.task "task"}
${optionalString (!job.task && job.respawn) "respawn"}
${optionalString job.restartIfChanged "# RESTART-IF-CHANGED"}
${ # preStop is run only if there is exec or script.
# (upstart 0.6.5, job.c:562)
optionalString (job.preStop != "") (assert hasMain; ''
@ -283,6 +285,15 @@ let
'';
};
restartIfChanged = mkOption {
type = types.bool;
default = true;
description = ''
Whether the job should be restarted if it has changed after a
NixOS configuration switch.
'';
};
task = mkOption {
type = types.bool;
default = false;

View File

@ -140,6 +140,8 @@ in
stopOn = "starting shutdown and stopping xend";
restartIfChanged = false;
path = [ pkgs.xen ];
environment.XENDOM_CONFIG = "${xen}/etc/sysconfig/xendomains";