mercurial/commands.py
changeset 1741 9777298fed84
parent 1740 f95654385065
child 1742 1e5bb6c929cd
equal deleted inserted replaced
1740:f95654385065 1741:9777298fed84
  2020     optlist = "name templates style address port ipv6 accesslog errorlog"
  2020     optlist = "name templates style address port ipv6 accesslog errorlog"
  2021     for o in optlist.split():
  2021     for o in optlist.split():
  2022         if opts[o]:
  2022         if opts[o]:
  2023             ui.setconfig("web", o, opts[o])
  2023             ui.setconfig("web", o, opts[o])
  2024 
  2024 
  2025     if opts['daemon'] and not opts['daemon_pipefd']:
  2025     if opts['daemon'] and not opts['daemon_pipefds']:
  2026         rfd, wfd = os.pipe()
  2026         rfd, wfd = os.pipe()
  2027         args = sys.argv[:]
  2027         args = sys.argv[:]
  2028         args.append('--daemon-pipefd=' + str(wfd))
  2028         args.append('--daemon-pipefds=%d,%d' % (rfd, wfd))
  2029         pid = os.spawnvp(os.P_NOWAIT | getattr(os, 'P_DETACH', 0),
  2029         pid = os.spawnvp(os.P_NOWAIT | getattr(os, 'P_DETACH', 0),
  2030                          args[0], args)
  2030                          args[0], args)
  2031         os.close(wfd)
  2031         os.close(wfd)
  2032         os.read(rfd, 1)
  2032         os.read(rfd, 1)
  2033         os._exit(0)
  2033         os._exit(0)
  2054     if opts['pid_file']:
  2054     if opts['pid_file']:
  2055         fp = open(opts['pid_file'], 'w')
  2055         fp = open(opts['pid_file'], 'w')
  2056         fp.write(str(os.getpid()))
  2056         fp.write(str(os.getpid()))
  2057         fp.close()
  2057         fp.close()
  2058 
  2058 
  2059     if opts['daemon_pipefd']:
  2059     if opts['daemon_pipefds']:
  2060         wfd = int(opts['daemon_pipefd'])
  2060         rfd, wfd = [int(x) for x in opts['daemon_pipefds'].split(',')]
       
  2061         os.close(rfd)
  2061         os.write(wfd, 'y')
  2062         os.write(wfd, 'y')
  2062         os.close(wfd)
  2063         os.close(wfd)
  2063         sys.stdout.flush()
  2064         sys.stdout.flush()
  2064         sys.stderr.flush()
  2065         sys.stderr.flush()
  2065         fd = os.open(util.nulldev, os.O_RDWR)
  2066         fd = os.open(util.nulldev, os.O_RDWR)
  2503     "root": (root, [], _('hg root')),
  2504     "root": (root, [], _('hg root')),
  2504     "^serve":
  2505     "^serve":
  2505         (serve,
  2506         (serve,
  2506          [('A', 'accesslog', '', _('name of access log file to write to')),
  2507          [('A', 'accesslog', '', _('name of access log file to write to')),
  2507           ('d', 'daemon', None, _('run server in background')),
  2508           ('d', 'daemon', None, _('run server in background')),
  2508           ('', 'daemon-pipefd', '', ''),
  2509           ('', 'daemon-pipefds', '', ''),
  2509           ('E', 'errorlog', '', _('name of error log file to write to')),
  2510           ('E', 'errorlog', '', _('name of error log file to write to')),
  2510           ('p', 'port', 0, _('port to use (default: 8000)')),
  2511           ('p', 'port', 0, _('port to use (default: 8000)')),
  2511           ('a', 'address', '', _('address to use')),
  2512           ('a', 'address', '', _('address to use')),
  2512           ('n', 'name', '',
  2513           ('n', 'name', '',
  2513            _('name to show in web pages (default: working dir)')),
  2514            _('name to show in web pages (default: working dir)')),