comparison mercurial/server.py @ 37120:a8a902d7176e

procutil: bulk-replace function calls to point to new module
author Yuya Nishihara <yuya@tcha.org>
date Sat, 24 Mar 2018 15:10:51 +0900
parents d4a2e0d5d042
children f09a2eab11cf
comparison
equal deleted inserted replaced
37119:d4a2e0d5d042 37120:a8a902d7176e
44 # Signal child process startup with file removal 44 # Signal child process startup with file removal
45 lockfd, lockpath = tempfile.mkstemp(prefix='hg-service-') 45 lockfd, lockpath = tempfile.mkstemp(prefix='hg-service-')
46 os.close(lockfd) 46 os.close(lockfd)
47 try: 47 try:
48 if not runargs: 48 if not runargs:
49 runargs = util.hgcmd() + pycompat.sysargv[1:] 49 runargs = procutil.hgcmd() + pycompat.sysargv[1:]
50 runargs.append('--daemon-postexec=unlink:%s' % lockpath) 50 runargs.append('--daemon-postexec=unlink:%s' % lockpath)
51 # Don't pass --cwd to the child process, because we've already 51 # Don't pass --cwd to the child process, because we've already
52 # changed directory. 52 # changed directory.
53 for i in xrange(1, len(runargs)): 53 for i in xrange(1, len(runargs)):
54 if runargs[i].startswith('--cwd='): 54 if runargs[i].startswith('--cwd='):
57 elif runargs[i].startswith('--cwd'): 57 elif runargs[i].startswith('--cwd'):
58 del runargs[i:i + 2] 58 del runargs[i:i + 2]
59 break 59 break
60 def condfn(): 60 def condfn():
61 return not os.path.exists(lockpath) 61 return not os.path.exists(lockpath)
62 pid = util.rundetached(runargs, condfn) 62 pid = procutil.rundetached(runargs, condfn)
63 if pid < 0: 63 if pid < 0:
64 raise error.Abort(_('child process failed to start')) 64 raise error.Abort(_('child process failed to start'))
65 writepid(pid) 65 writepid(pid)
66 finally: 66 finally:
67 util.tryunlink(lockpath) 67 util.tryunlink(lockpath)
72 72
73 if initfn: 73 if initfn:
74 initfn() 74 initfn()
75 75
76 if not opts['daemon']: 76 if not opts['daemon']:
77 writepid(util.getpid()) 77 writepid(procutil.getpid())
78 78
79 if opts['daemon_postexec']: 79 if opts['daemon_postexec']:
80 try: 80 try:
81 os.setsid() 81 os.setsid()
82 except AttributeError: 82 except AttributeError:
88 elif inst.startswith('chdir:'): 88 elif inst.startswith('chdir:'):
89 os.chdir(inst[6:]) 89 os.chdir(inst[6:])
90 elif inst != 'none': 90 elif inst != 'none':
91 raise error.Abort(_('invalid value for --daemon-postexec: %s') 91 raise error.Abort(_('invalid value for --daemon-postexec: %s')
92 % inst) 92 % inst)
93 util.hidewindow() 93 procutil.hidewindow()
94 procutil.stdout.flush() 94 procutil.stdout.flush()
95 procutil.stderr.flush() 95 procutil.stderr.flush()
96 96
97 nullfd = os.open(os.devnull, os.O_RDWR) 97 nullfd = os.open(os.devnull, os.O_RDWR)
98 logfilefd = nullfd 98 logfilefd = nullfd