Fixing the postfix start/stop (through an upstart job script code that will

monitor the life of postfix)

Adding an assert to upstart jobs, so those with preStop will always need an exec or
script, otherwise the preStop will not be run.


svn path=/nixos/trunk/; revision=22225
This commit is contained in:
Lluís Batlle i Rossell 2010-06-11 21:44:06 +00:00
parent dadd6d63e7
commit b25771532a
2 changed files with 14 additions and 3 deletions

View File

@ -287,7 +287,15 @@ in
daemonType = "none"; daemonType = "none";
respawn = false; respawn = true;
script = ''
while ${pkgs.procps}/bin/ps `${pkgs.coreutils}/bin/cat /var/postfix/queue/pid/master.pid` |
grep -q postfix
do
${pkgs.coreutils}/bin/sleep 1m
done
'';
preStart = preStart =
'' ''

View File

@ -21,6 +21,7 @@ let
makeJob = job: makeJob = job:
let let
hasMain = job.script != "" || job.exec != "";
jobText = jobText =
let log = "/var/log/upstart/${job.name}"; in let log = "/var/log/upstart/${job.name}"; in
@ -77,12 +78,14 @@ let
${optionalString job.task "task"} ${optionalString job.task "task"}
${optionalString (!job.task && job.respawn) "respawn"} ${optionalString (!job.task && job.respawn) "respawn"}
${optionalString (job.preStop != "") '' ${ # preStop is run only if there is exec or script.
# (upstart 0.6.5, job.c:562)
optionalString (job.preStop != "") (assert hasMain; ''
pre-stop script pre-stop script
exec >> ${log} 2>&1 exec >> ${log} 2>&1
${job.preStop} ${job.preStop}
end script end script
''} '')}
${optionalString (job.postStop != "") '' ${optionalString (job.postStop != "") ''
post-stop script post-stop script