mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-14 06:00:33 +03:00
* 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:
parent
3495a773f9
commit
86d8d62d16
6 changed files with 22 additions and 10 deletions
|
@ -126,6 +126,8 @@ in
|
||||||
+ optionalString config.services.tomcat.enable " and started tomcat"
|
+ optionalString config.services.tomcat.enable " and started tomcat"
|
||||||
+ optionalString config.services.svnserve.enable " and started svnserve";
|
+ optionalString config.services.svnserve.enable " and started svnserve";
|
||||||
|
|
||||||
|
restartIfChanged = false;
|
||||||
|
|
||||||
script =
|
script =
|
||||||
''
|
''
|
||||||
export PATH=/var/run/current-system/sw/bin:/var/run/current-system/sw/sbin
|
export PATH=/var/run/current-system/sw/bin:/var/run/current-system/sw/sbin
|
||||||
|
|
|
@ -118,6 +118,8 @@ in
|
||||||
jobs.dbus =
|
jobs.dbus =
|
||||||
{ startOn = "started udev and started syslogd";
|
{ startOn = "started udev and started syslogd";
|
||||||
|
|
||||||
|
restartIfChanged = false;
|
||||||
|
|
||||||
path = [ pkgs.dbus_daemon pkgs.dbus_tools ];
|
path = [ pkgs.dbus_daemon pkgs.dbus_tools ];
|
||||||
|
|
||||||
preStart =
|
preStart =
|
||||||
|
|
|
@ -392,7 +392,9 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
jobs.xserver =
|
jobs.xserver =
|
||||||
{ environment =
|
{ restartIfChanged = false;
|
||||||
|
|
||||||
|
environment =
|
||||||
{ FONTCONFIG_FILE = "/etc/fonts/fonts.conf"; # !!! cleanup
|
{ FONTCONFIG_FILE = "/etc/fonts/fonts.conf"; # !!! cleanup
|
||||||
XKB_BINDIR = "${xorg.xkbcomp}/bin"; # Needed for the Xkb extension.
|
XKB_BINDIR = "${xorg.xkbcomp}/bin"; # Needed for the Xkb extension.
|
||||||
TZ = config.time.timeZone;
|
TZ = config.time.timeZone;
|
||||||
|
|
|
@ -108,14 +108,7 @@ for job in $(cd $newJobs && ls *.conf); do
|
||||||
status=$(status "$job")
|
status=$(status "$job")
|
||||||
if ! [[ "$status" =~ start/ ]]; then continue; fi
|
if ! [[ "$status" =~ start/ ]]; then continue; fi
|
||||||
if [ "$(readlink -f "$newJobs/$job.conf")" = "$(readlink -f "/var/run/upstart-jobs/$job")" ]; 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).
|
if ! grep -q "^# RESTART-IF-CHANGED" "$newJobs/$job.conf"; then
|
||||||
# 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
|
|
||||||
echo "not restarting changed service ‘$job’"
|
echo "not restarting changed service ‘$job’"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -82,6 +82,8 @@ let
|
||||||
${optionalString job.task "task"}
|
${optionalString job.task "task"}
|
||||||
${optionalString (!job.task && job.respawn) "respawn"}
|
${optionalString (!job.task && job.respawn) "respawn"}
|
||||||
|
|
||||||
|
${optionalString job.restartIfChanged "# RESTART-IF-CHANGED"}
|
||||||
|
|
||||||
${ # preStop is run only if there is exec or script.
|
${ # preStop is run only if there is exec or script.
|
||||||
# (upstart 0.6.5, job.c:562)
|
# (upstart 0.6.5, job.c:562)
|
||||||
optionalString (job.preStop != "") (assert hasMain; ''
|
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 {
|
task = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
|
|
|
@ -140,6 +140,8 @@ in
|
||||||
|
|
||||||
stopOn = "starting shutdown and stopping xend";
|
stopOn = "starting shutdown and stopping xend";
|
||||||
|
|
||||||
|
restartIfChanged = false;
|
||||||
|
|
||||||
path = [ pkgs.xen ];
|
path = [ pkgs.xen ];
|
||||||
|
|
||||||
environment.XENDOM_CONFIG = "${xen}/etc/sysconfig/xendomains";
|
environment.XENDOM_CONFIG = "${xen}/etc/sysconfig/xendomains";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue