* Support pre-stop scripts. These are needed to cleanly shutdown

daemons such as Apache or PostgreSQL.

svn path=/nixos/branches/upstart-0.6/; revision=18234
This commit is contained in:
Eelco Dolstra 2009-11-06 22:45:19 +00:00
parent 83a9bf9a6a
commit d7342c78d4
2 changed files with 24 additions and 1 deletions

View file

@ -480,7 +480,14 @@ in
done
'';
exec = "${httpd}/bin/httpd -f ${httpdConf} -DNO_DETACH";
daemonType = "fork";
exec = "${httpd}/bin/httpd -f ${httpdConf}";
preStop =
''
${httpd}/bin/httpd -f ${httpdConf} -k graceful-stop
'';
};
};

View file

@ -72,6 +72,12 @@ let
${optionalString job.task "task"}
${optionalString job.respawn "respawn"}
${optionalString (job.preStop != "") ''
pre-stop script
${job.preStop}
end script
''}
${optionalString (job.postStop != "") ''
post-stop script
${job.postStop}
@ -165,6 +171,16 @@ let
'';
};
preStop = mkOption {
type = types.string;
default = "";
description = ''
Shell commands executed before the job is stopped
(i.e. before Upstart kills the job's main process). This can
be used to cleanly shut down a daemon.
'';
};
postStop = mkOption {
type = types.string;
default = "";