equal
deleted
inserted
replaced
556 ui.warn(_('(consider using --after)\n')) |
556 ui.warn(_('(consider using --after)\n')) |
557 |
557 |
558 return errors |
558 return errors |
559 |
559 |
560 def service(opts, parentfn=None, initfn=None, runfn=None, logfile=None, |
560 def service(opts, parentfn=None, initfn=None, runfn=None, logfile=None, |
561 runargs=None): |
561 runargs=None, appendpid=False): |
562 '''Run a command as a service.''' |
562 '''Run a command as a service.''' |
563 |
563 |
564 if opts['daemon'] and not opts['daemon_pipefds']: |
564 if opts['daemon'] and not opts['daemon_pipefds']: |
565 rfd, wfd = os.pipe() |
565 rfd, wfd = os.pipe() |
566 if not runargs: |
566 if not runargs: |
586 |
586 |
587 if initfn: |
587 if initfn: |
588 initfn() |
588 initfn() |
589 |
589 |
590 if opts['pid_file']: |
590 if opts['pid_file']: |
591 fp = open(opts['pid_file'], 'w') |
591 mode = appendpid and 'a' or 'w' |
|
592 fp = open(opts['pid_file'], mode) |
592 fp.write(str(os.getpid()) + '\n') |
593 fp.write(str(os.getpid()) + '\n') |
593 fp.close() |
594 fp.close() |
594 |
595 |
595 if opts['daemon_pipefds']: |
596 if opts['daemon_pipefds']: |
596 rfd, wfd = [int(x) for x in opts['daemon_pipefds'].split(',')] |
597 rfd, wfd = [int(x) for x in opts['daemon_pipefds'].split(',')] |