##// END OF EJS Templates
cmdutil: service: add an optional runargs argument to pass the command to run...
Nicolas Dumazet -
r9513:ae88c721 default
parent child Browse files
Show More
@@ -546,24 +546,26 b' def copy(ui, repo, pats, opts, rename=Fa'
546 546
547 547 return errors
548 548
549 def service(opts, parentfn=None, initfn=None, runfn=None, logfile=None):
549 def service(opts, parentfn=None, initfn=None, runfn=None, logfile=None,
550 runargs=None):
550 551 '''Run a command as a service.'''
551 552
552 553 if opts['daemon'] and not opts['daemon_pipefds']:
553 554 rfd, wfd = os.pipe()
554 args = sys.argv[:]
555 args.append('--daemon-pipefds=%d,%d' % (rfd, wfd))
555 if not runargs:
556 runargs = sys.argv[:]
557 runargs.append('--daemon-pipefds=%d,%d' % (rfd, wfd))
556 558 # Don't pass --cwd to the child process, because we've already
557 559 # changed directory.
558 for i in xrange(1,len(args)):
559 if args[i].startswith('--cwd='):
560 del args[i]
560 for i in xrange(1,len(runargs)):
561 if runargs[i].startswith('--cwd='):
562 del runargs[i]
561 563 break
562 elif args[i].startswith('--cwd'):
563 del args[i:i+2]
564 elif runargs[i].startswith('--cwd'):
565 del runargs[i:i+2]
564 566 break
565 567 pid = os.spawnvp(os.P_NOWAIT | getattr(os, 'P_DETACH', 0),
566 args[0], args)
568 runargs[0], runargs)
567 569 os.close(wfd)
568 570 os.read(rfd, 1)
569 571 if parentfn:
General Comments 0
You need to be logged in to leave comments. Login now