mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Make Worker.pid useful in master process
This commit is contained in:
parent
53fd1c1071
commit
f671d51f76
@ -548,14 +548,15 @@ class Arbiter(object):
|
||||
self.cfg.pre_fork(self, worker)
|
||||
pid = os.fork()
|
||||
if pid != 0:
|
||||
worker.pid = pid
|
||||
self.WORKERS[pid] = worker
|
||||
return pid
|
||||
|
||||
# Process Child
|
||||
worker_pid = os.getpid()
|
||||
worker.pid = os.getpid()
|
||||
try:
|
||||
util._setproctitle("worker [%s]" % self.proc_name)
|
||||
self.log.info("Booting worker with pid: %s", worker_pid)
|
||||
self.log.info("Booting worker with pid: %s", worker.pid)
|
||||
self.cfg.post_fork(self, worker)
|
||||
worker.init_process()
|
||||
sys.exit(0)
|
||||
@ -573,7 +574,7 @@ class Arbiter(object):
|
||||
sys.exit(self.WORKER_BOOT_ERROR)
|
||||
sys.exit(-1)
|
||||
finally:
|
||||
self.log.info("Worker exiting (pid: %s)", worker_pid)
|
||||
self.log.info("Worker exiting (pid: %s)", worker.pid)
|
||||
try:
|
||||
worker.tmp.close()
|
||||
self.cfg.worker_exit(self, worker)
|
||||
|
||||
@ -38,6 +38,7 @@ class Worker(object):
|
||||
changes you'll want to do that in ``self.init_process()``.
|
||||
"""
|
||||
self.age = age
|
||||
self.pid = "[booting]"
|
||||
self.ppid = ppid
|
||||
self.sockets = sockets
|
||||
self.app = app
|
||||
@ -57,10 +58,6 @@ class Worker(object):
|
||||
def __str__(self):
|
||||
return "<Worker %s>" % self.pid
|
||||
|
||||
@property
|
||||
def pid(self):
|
||||
return os.getpid()
|
||||
|
||||
def notify(self):
|
||||
"""\
|
||||
Your worker subclass must arrange to have this method called
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user