##// END OF EJS Templates
cmdutil.service: move pidfile writing to a local function...
Siddharth Agarwal -
r19867:edce20eb default
parent child Browse files
Show More
@@ -468,6 +468,13 b' def service(opts, parentfn=None, initfn='
468 runargs=None, appendpid=False):
468 runargs=None, appendpid=False):
469 '''Run a command as a service.'''
469 '''Run a command as a service.'''
470
470
471 def writepid(pid):
472 if opts['pid_file']:
473 mode = appendpid and 'a' or 'w'
474 fp = open(opts['pid_file'], mode)
475 fp.write(str(pid) + '\n')
476 fp.close()
477
471 if opts['daemon'] and not opts['daemon_pipefds']:
478 if opts['daemon'] and not opts['daemon_pipefds']:
472 # Signal child process startup with file removal
479 # Signal child process startup with file removal
473 lockfd, lockpath = tempfile.mkstemp(prefix='hg-service-')
480 lockfd, lockpath = tempfile.mkstemp(prefix='hg-service-')
@@ -504,11 +511,7 b' def service(opts, parentfn=None, initfn='
504 if initfn:
511 if initfn:
505 initfn()
512 initfn()
506
513
507 if opts['pid_file']:
514 writepid(os.getpid())
508 mode = appendpid and 'a' or 'w'
509 fp = open(opts['pid_file'], mode)
510 fp.write(str(os.getpid()) + '\n')
511 fp.close()
512
515
513 if opts['daemon_pipefds']:
516 if opts['daemon_pipefds']:
514 lockpath = opts['daemon_pipefds']
517 lockpath = opts['daemon_pipefds']
General Comments 0
You need to be logged in to leave comments. Login now