equal
deleted
inserted
replaced
33 # XXX unix specific |
33 # XXX unix specific |
34 # XXX factorize w/ code in cw.server.server and cw.server.serverctl |
34 # XXX factorize w/ code in cw.server.server and cw.server.serverctl |
35 # (start-repository command) |
35 # (start-repository command) |
36 # See http://www.erlenstar.demon.co.uk/unix/faq_toc.html#TOC16 |
36 # See http://www.erlenstar.demon.co.uk/unix/faq_toc.html#TOC16 |
37 if os.fork(): # launch child and... |
37 if os.fork(): # launch child and... |
38 return -1 |
38 os._exit(0) |
39 os.setsid() |
39 os.setsid() |
40 if os.fork(): # launch child and... |
40 if os.fork(): # launch child and... |
41 os._exit(0) # kill off parent again. |
41 os._exit(0) # kill off parent again. |
42 # move to the root to avoit mount pb |
42 # move to the root to avoit mount pb |
43 os.chdir('/') |
43 os.chdir('/') |
377 reactor.listenTCP(port, channel.HTTPFactory(website)) |
377 reactor.listenTCP(port, channel.HTTPFactory(website)) |
378 baseurl = config['base-url'] or config.default_base_url() |
378 baseurl = config['base-url'] or config.default_base_url() |
379 logger = getLogger('cubicweb.twisted') |
379 logger = getLogger('cubicweb.twisted') |
380 logger.info('instance started on %s', baseurl) |
380 logger.info('instance started on %s', baseurl) |
381 if not debug: |
381 if not debug: |
382 if daemonize(): |
382 print 'instance starting in the background' |
383 # child process |
383 daemonize() |
384 return |
|
385 if config['pid-file']: |
384 if config['pid-file']: |
386 # ensure the directory where the pid-file should be set exists (for |
385 # ensure the directory where the pid-file should be set exists (for |
387 # instance /var/run/cubicweb may be deleted on computer restart) |
386 # instance /var/run/cubicweb may be deleted on computer restart) |
388 piddir = os.path.dirname(config['pid-file']) |
387 piddir = os.path.dirname(config['pid-file']) |
389 if not os.path.exists(piddir): |
388 if not os.path.exists(piddir): |
390 os.makedirs(piddir) |
389 os.makedirs(piddir) |
391 file(config['pid-file'], 'w').write(str(os.getpid())) |
390 file(config['pid-file'], 'w').write(str(os.getpid())) |
392 if config['uid'] is not None: |
391 if config['uid'] is not None: |