[PATCH 1 of 2] cmdutil: service: add appendpid parameter to append pids to pid file

Nicolas Dumazet nicdumz at gmail.com
Tue Dec 1 02:58:17 UTC 2009


# HG changeset patch
# User Nicolas Dumazet <nicdumz.commits at gmail.com>
# Date 1259634511 -32400
# Node ID f1f0073b8e32bddbba9f527c0cc356fb37fb5455
# Parent  2e67734e1453e44de0816c3f562005e89c09c21f
cmdutil: service: add appendpid parameter to append pids to pid file

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -558,7 +558,7 @@
     return errors
 
 def service(opts, parentfn=None, initfn=None, runfn=None, logfile=None,
-    runargs=None):
+    runargs=None, appendpid=False):
     '''Run a command as a service.'''
 
     if opts['daemon'] and not opts['daemon_pipefds']:
@@ -588,7 +588,8 @@
         initfn()
 
     if opts['pid_file']:
-        fp = open(opts['pid_file'], 'w')
+        mode = appendpid and 'a' or 'w'
+        fp = open(opts['pid_file'], mode)
         fp.write(str(os.getpid()) + '\n')
         fp.close()
 


More information about the Mercurial-devel mailing list