From 85ec7b3ebc7c8dcf65ecc3bab0533825e695af8c Mon Sep 17 00:00:00 2001 From: benoitc Date: Wed, 10 Mar 2010 21:04:26 +0100 Subject: [PATCH] fix pid --- doc/htdocs/configuration.html | 12 ++++-------- doc/htdocs/deployment.html | 2 +- doc/htdocs/news.html | 22 ++++++++++++++++++---- gunicorn/arbiter.py | 11 +++++++---- 4 files changed, 30 insertions(+), 17 deletions(-) diff --git a/doc/htdocs/configuration.html b/doc/htdocs/configuration.html index fda259fd..b0b8787c 100644 --- a/doc/htdocs/configuration.html +++ b/doc/htdocs/configuration.html @@ -66,16 +66,12 @@ group = None # Change process group to group proc_name = None # Change the process name tmp_upload_dir = None # Set path used to store temporary uploads -def after_fork(server, worker): - fmt = "worker=%s spawned pid=%s" - server.log.info(fmt % (worker.id, worker.pid)) +after_fork=lambda server, worker: server.log.info( + "Worker spawned (pid: %s)" % worker.pid), -def before_fork(server, worker): - fmt = "worker=%s spawning" - server.log.info(fmt % worker.id) +before_fork=lambda server, worker: True, -def before_exec(server): - serer.log.info("Forked child, reexecuting.") +before_exec=lambda server: server.log.info("Forked child, reexecuting"
diff --git a/doc/htdocs/deployment.html b/doc/htdocs/deployment.html index c7c15ab0..0a20eeff 100644 --- a/doc/htdocs/deployment.html +++ b/doc/htdocs/deployment.html @@ -127,7 +127,7 @@ exec $GUNICORN -C $ROOT/gunicorn.conf.py --pidfile=$PID $APP simple configuration is:

 [program:gunicorn]
-command=/usr/local/bin/gunicorn main:application -C /path/to/project/gunicorn.conf.py
+command=/usr/local/bin/gunicorn main:application -c /path/to/project/gunicorn.conf.py
 directory=/path/to/project
 user=nobody
 autostart=true
diff --git a/doc/htdocs/news.html b/doc/htdocs/news.html
index 96c29e96..ff8449ca 100644
--- a/doc/htdocs/news.html
+++ b/doc/htdocs/news.html
@@ -50,6 +50,20 @@
   

News

+

0.6.4 / 2010-03-08

+
    +
  • Use cStringIO when it's possible (use less CPU and faster)
  • +
  • Fix worker freeze when a remote connexion close unexpectedly.
  • +
+
+
+

0.6.3 / 2010-03-07

+
    +
  • Make HTTP parsing faster.
  • +
  • Some fixes (see logs)
  • +
+
+

0.6.2 / 2010-03-01

  • Added support for chunked response.
  • @@ -59,7 +73,7 @@
  • Workers are now murdered by age (the older is killed the first).
-
+

0.6.1 / 2010-02-24

  • Added gunicorn config file support for django admin command
  • @@ -67,21 +81,21 @@
  • Removed TTIN/TTOU from workers which blocked other signals.
-
+

0.6 / 2010-02-22

  • Added setproctitle
  • Change privilege switch behaviour. We now works like NGINX, master keep the permission, new uid/gid permissions are only set to the workers.
-
+

0.5.1 / 2010-02-22

  • Fix umask
  • Added debian packaging
-
+

0.5 / 2010-02-20

  • Added configuration file handler.
  • diff --git a/gunicorn/arbiter.py b/gunicorn/arbiter.py index 551d7596..c194b245 100644 --- a/gunicorn/arbiter.py +++ b/gunicorn/arbiter.py @@ -100,7 +100,8 @@ class Arbiter(object): return pid = self.valid_pidfile(path) if pid: - if self.pidfile and path == self.pidfile and pid == os.getpid(): + if self._pidfile is not None and path == self._pidfile and \ + pid == os.getpid(): return path raise RuntimeError("Already running on PID %s " \ "(or pid file '%s' is stale)" % (os.getpid(), path)) @@ -120,8 +121,10 @@ class Arbiter(object): """ delete pidfile""" try: with open(path, "r") as f: - if int(f.read() or 0) == self.pid: - os.unlink(f) + pid = int(f.read() or 0) + + if pid == self.pid: + os.unlink(path) except: pass @@ -335,7 +338,7 @@ class Arbiter(object): """ if self.pidfile: old_pidfile = "%s.oldbin" % self.pidfile - self.pidfile = old_pidfile + self.pidfile = old_pidfile self.reexec_pid = os.fork() if self.reexec_pid != 0: