From b25771532af934ea18589f237cfa57da2430fea4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Fri, 11 Jun 2010 21:44:06 +0000 Subject: [PATCH] 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 --- modules/services/mail/postfix.nix | 10 +++++++++- modules/system/upstart/upstart.nix | 7 +++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/modules/services/mail/postfix.nix b/modules/services/mail/postfix.nix index 939260632c9b..03c77885d069 100644 --- a/modules/services/mail/postfix.nix +++ b/modules/services/mail/postfix.nix @@ -287,7 +287,15 @@ in 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 = '' diff --git a/modules/system/upstart/upstart.nix b/modules/system/upstart/upstart.nix index 3110f376eece..cb3975e694c3 100644 --- a/modules/system/upstart/upstart.nix +++ b/modules/system/upstart/upstart.nix @@ -21,6 +21,7 @@ let makeJob = job: let + hasMain = job.script != "" || job.exec != ""; jobText = let log = "/var/log/upstart/${job.name}"; in @@ -77,12 +78,14 @@ let ${optionalString job.task "task"} ${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 exec >> ${log} 2>&1 ${job.preStop} end script - ''} + '')} ${optionalString (job.postStop != "") '' post-stop script