mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
fix issue #57 and make sure target dir of pidfile exists.
This commit is contained in:
parent
ed17054137
commit
fdf8169a2c
@ -95,8 +95,10 @@ class Arbiter(object):
|
|||||||
self.pid = os.getpid()
|
self.pid = os.getpid()
|
||||||
self.init_signals()
|
self.init_signals()
|
||||||
self.LISTENER = create_socket(self.cfg)
|
self.LISTENER = create_socket(self.cfg)
|
||||||
self.pidfile = Pidfile(self.cfg.pidfile)
|
|
||||||
self.pidfile.create(self.pid)
|
if self.cfg.pidfile is not None:
|
||||||
|
self.pidfile = Pidfile(self.cfg.pidfile)
|
||||||
|
self.pidfile.create(self.pid)
|
||||||
self.log.info("Arbiter booted")
|
self.log.info("Arbiter booted")
|
||||||
self.log.info("Listening at: %s" % self.LISTENER)
|
self.log.info("Listening at: %s" % self.LISTENER)
|
||||||
|
|
||||||
|
|||||||
@ -32,7 +32,10 @@ class Pidfile(object):
|
|||||||
self.pid = pid
|
self.pid = pid
|
||||||
|
|
||||||
# Write pidfile
|
# Write pidfile
|
||||||
fd, fname = tempfile.mkstemp(dir=os.path.dirname(self.fname))
|
fdir = os.path.dirname(self.fname)
|
||||||
|
if not os.path.isdir(fdir):
|
||||||
|
raise RuntimeError("%s don't exist. Can't create pidfile" % fdir)
|
||||||
|
fd, fname = tempfile.mkstemp(dir=fdir)
|
||||||
os.write(fd, "%s\n" % self.pid)
|
os.write(fd, "%s\n" % self.pid)
|
||||||
if self.fname:
|
if self.fname:
|
||||||
os.rename(fname, self.fname)
|
os.rename(fname, self.fname)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user