summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-03-18 02:10:39 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-03-18 02:10:39 +0000
commit86d8d62d16edb4c66072eda6fc31fcaba02cacd2 (patch)
tree66f14b51ffc352102f1803143ccf3e86176e5304
parent3495a773f947105b88f375b525e3045b518443f9 (diff)
downloadnixlib-86d8d62d16edb4c66072eda6fc31fcaba02cacd2.tar
nixlib-86d8d62d16edb4c66072eda6fc31fcaba02cacd2.tar.gz
nixlib-86d8d62d16edb4c66072eda6fc31fcaba02cacd2.tar.bz2
nixlib-86d8d62d16edb4c66072eda6fc31fcaba02cacd2.tar.lz
nixlib-86d8d62d16edb4c66072eda6fc31fcaba02cacd2.tar.xz
nixlib-86d8d62d16edb4c66072eda6fc31fcaba02cacd2.tar.zst
nixlib-86d8d62d16edb4c66072eda6fc31fcaba02cacd2.zip
* 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
-rw-r--r--modules/services/misc/disnix.nix2
-rw-r--r--modules/services/system/dbus.nix4
-rw-r--r--modules/services/x11/xserver.nix4
-rw-r--r--modules/system/activation/switch-to-configuration.sh9
-rw-r--r--modules/system/upstart/upstart.nix11
-rw-r--r--modules/virtualisation/xen-dom0.nix2
6 files changed, 22 insertions, 10 deletions
diff --git a/modules/services/misc/disnix.nix b/modules/services/misc/disnix.nix
index 10c507808f5a..c03a60361328 100644
--- a/modules/services/misc/disnix.nix
+++ b/modules/services/misc/disnix.nix
@@ -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
diff --git a/modules/services/system/dbus.nix b/modules/services/system/dbus.nix
index a9d7a3d8420b..b01cd7bc2ff2 100644
--- a/modules/services/system/dbus.nix
+++ b/modules/services/system/dbus.nix
@@ -117,7 +117,9 @@ in
 
     jobs.dbus =
       { startOn = "started udev and started syslogd";
-
+      
+        restartIfChanged = false;
+        
         path = [ pkgs.dbus_daemon pkgs.dbus_tools ];
 
         preStart =
diff --git a/modules/services/x11/xserver.nix b/modules/services/x11/xserver.nix
index da29faabcfd9..3664264cbc3e 100644
--- a/modules/services/x11/xserver.nix
+++ b/modules/services/x11/xserver.nix
@@ -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;
diff --git a/modules/system/activation/switch-to-configuration.sh b/modules/system/activation/switch-to-configuration.sh
index 07b24d237272..abd06c1e9b3a 100644
--- a/modules/system/activation/switch-to-configuration.sh
+++ b/modules/system/activation/switch-to-configuration.sh
@@ -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
diff --git a/modules/system/upstart/upstart.nix b/modules/system/upstart/upstart.nix
index c7203d5672be..d73a19653a7f 100644
--- a/modules/system/upstart/upstart.nix
+++ b/modules/system/upstart/upstart.nix
@@ -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;
diff --git a/modules/virtualisation/xen-dom0.nix b/modules/virtualisation/xen-dom0.nix
index 8c2f6c738c12..77bf5ea8b7e0 100644
--- a/modules/virtualisation/xen-dom0.nix
+++ b/modules/virtualisation/xen-dom0.nix
@@ -140,6 +140,8 @@ in
 
         stopOn = "starting shutdown and stopping xend";
 
+        restartIfChanged = false;
+        
         path = [ pkgs.xen ];
 
         environment.XENDOM_CONFIG = "${xen}/etc/sysconfig/xendomains";