mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
some fixes. Now we have daemonized mode and pidfile.
This commit is contained in:
parent
ced1f39020
commit
4be8e9f0ee
@ -206,10 +206,10 @@ class Arbiter(object):
|
|||||||
except StopIteration:
|
except StopIteration:
|
||||||
break
|
break
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
self.stop(False)
|
self.stop()
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
except Exception:
|
except Exception:
|
||||||
self.log.exception("Unhandled exception in main loop.")
|
self.log.info("Unhandled exception in main loop.")
|
||||||
self.stop(False)
|
self.stop(False)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
|
|||||||
@ -32,7 +32,7 @@ def options():
|
|||||||
help='Number of workers to spawn. [%default]'),
|
help='Number of workers to spawn. [%default]'),
|
||||||
op.make_option('-p','--pid', dest='pidfile',
|
op.make_option('-p','--pid', dest='pidfile',
|
||||||
help='set the background PID FILE'),
|
help='set the background PID FILE'),
|
||||||
op.make_option('-D', '--daemon', dest='daemon',
|
op.make_option('-D', '--daemon', dest='daemon', action="store_true",
|
||||||
help='Run daemonized in the background.'),
|
help='Run daemonized in the background.'),
|
||||||
op.make_option('--log-level', dest='loglevel', default='info',
|
op.make_option('--log-level', dest='loglevel', default='info',
|
||||||
help='Log level below which to silence messages. [%default]'),
|
help='Log level below which to silence messages. [%default]'),
|
||||||
@ -57,7 +57,7 @@ def configure_logging(opts):
|
|||||||
h.setFormatter(logging.Formatter("%(levelname)s %(message)s"))
|
h.setFormatter(logging.Formatter("%(levelname)s %(message)s"))
|
||||||
logger.addHandler(h)
|
logger.addHandler(h)
|
||||||
|
|
||||||
def daemonize(logger):
|
def daemonize():
|
||||||
if not 'GUNICORN_FD' in os.environ:
|
if not 'GUNICORN_FD' in os.environ:
|
||||||
if os.fork() == 0:
|
if os.fork() == 0:
|
||||||
os.setsid()
|
os.setsid()
|
||||||
@ -105,7 +105,6 @@ def main(usage, get_app):
|
|||||||
pidfile=opts.pidfile
|
pidfile=opts.pidfile
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
arbiter = Arbiter((host,port), workers, app,
|
arbiter = Arbiter((host,port), workers, app,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
if opts.daemon:
|
if opts.daemon:
|
||||||
|
|||||||
@ -125,12 +125,11 @@ class Worker(object):
|
|||||||
break
|
break
|
||||||
if e[0] == errno.EBADF:
|
if e[0] == errno.EBADF:
|
||||||
if nr >= 0:
|
if nr >= 0:
|
||||||
return
|
break
|
||||||
raise
|
raise
|
||||||
|
|
||||||
spinner = (spinner+1) % 2
|
spinner = (spinner+1) % 2
|
||||||
self._fchmod(spinner)
|
self._fchmod(spinner)
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
def handle(self, client, addr):
|
def handle(self, client, addr):
|
||||||
util.close_on_exec(client)
|
util.close_on_exec(client)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user