diff --git a/gunicorn/arbiter.py b/gunicorn/arbiter.py index c73eb1f1..cb330d48 100644 --- a/gunicorn/arbiter.py +++ b/gunicorn/arbiter.py @@ -95,8 +95,10 @@ class Arbiter(object): self.pid = os.getpid() self.init_signals() 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("Listening at: %s" % self.LISTENER) diff --git a/gunicorn/pidfile.py b/gunicorn/pidfile.py index 845d7427..8baa8878 100644 --- a/gunicorn/pidfile.py +++ b/gunicorn/pidfile.py @@ -32,7 +32,10 @@ class Pidfile(object): self.pid = pid # 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) if self.fname: os.rename(fname, self.fname)