cmdutil: service: add appendpid parameter to append pids to pid file
authorNicolas Dumazet <nicdumz.commits@gmail.com>
Tue, 01 Dec 2009 11:28:31 +0900
changeset 10012 2bfe1a23dafa
parent 10011 a9836feb5a8c
child 10013 b2e87fde6806
cmdutil: service: add appendpid parameter to append pids to pid file
mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Fri Dec 04 17:43:01 2009 +0100
+++ b/mercurial/cmdutil.py	Tue Dec 01 11:28:31 2009 +0900
@@ -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()