comparison mercurial/cmdutil.py @ 28194:7623ba92af72

serve: rename --daemon-pipefds to --daemon-postexec (BC) Initially we use --daemon-pipefds to pass file descriptors for synchronization. Later, in order to support Windows, --daemon-pipefds is changed to accept a file path to unlink instead. The name is outdated since then. chg client is designed to use flock, which will be held before starting a server and until the client actually connects to the server it started. The unlink synchronization approach is not so helpful in this case. To address the issues, this patch renames pipefds to postexec and the following patch will allow the value of --daemon-postexec to be things like 'unlink:/path/to/file' or 'none'.
author Jun Wu <quark@fb.com>
date Mon, 22 Feb 2016 16:59:08 +0000
parents ed4d06f180b8
children 213c8cf02c49
comparison
equal deleted inserted replaced
28193:19775bc34da3 28194:7623ba92af72
756 mode = 'w' 756 mode = 'w'
757 fp = open(opts['pid_file'], mode) 757 fp = open(opts['pid_file'], mode)
758 fp.write(str(pid) + '\n') 758 fp.write(str(pid) + '\n')
759 fp.close() 759 fp.close()
760 760
761 if opts['daemon'] and not opts['daemon_pipefds']: 761 if opts['daemon'] and not opts['daemon_postexec']:
762 # Signal child process startup with file removal 762 # Signal child process startup with file removal
763 lockfd, lockpath = tempfile.mkstemp(prefix='hg-service-') 763 lockfd, lockpath = tempfile.mkstemp(prefix='hg-service-')
764 os.close(lockfd) 764 os.close(lockfd)
765 try: 765 try:
766 if not runargs: 766 if not runargs:
767 runargs = util.hgcmd() + sys.argv[1:] 767 runargs = util.hgcmd() + sys.argv[1:]
768 runargs.append('--daemon-pipefds=%s' % lockpath) 768 runargs.append('--daemon-postexec=%s' % lockpath)
769 # Don't pass --cwd to the child process, because we've already 769 # Don't pass --cwd to the child process, because we've already
770 # changed directory. 770 # changed directory.
771 for i in xrange(1, len(runargs)): 771 for i in xrange(1, len(runargs)):
772 if runargs[i].startswith('--cwd='): 772 if runargs[i].startswith('--cwd='):
773 del runargs[i] 773 del runargs[i]
796 initfn() 796 initfn()
797 797
798 if not opts['daemon']: 798 if not opts['daemon']:
799 writepid(util.getpid()) 799 writepid(util.getpid())
800 800
801 if opts['daemon_pipefds']: 801 if opts['daemon_postexec']:
802 lockpath = opts['daemon_pipefds'] 802 lockpath = opts['daemon_postexec']
803 try: 803 try:
804 os.setsid() 804 os.setsid()
805 except AttributeError: 805 except AttributeError:
806 pass 806 pass
807 os.unlink(lockpath) 807 os.unlink(lockpath)