Write a pidfile for the Python services so we can manage them.
This commit is contained in:
parent
765f32809d
commit
dd178bb22e
@ -72,7 +72,7 @@ def configure_gunicorn():
|
||||
worker_class ="sync"
|
||||
debug = False
|
||||
daemon = True
|
||||
pidfile = "/tmp/gunicorn.pid"
|
||||
pidfile = "/var/run/gunicorn.pid"
|
||||
logfile = "/tmp/gunicorn.log"
|
||||
"""
|
||||
config = textwrap.dedent(config % args).lstrip()
|
||||
|
@ -16,7 +16,10 @@
|
||||
|
||||
|
||||
import argparse
|
||||
import atexit
|
||||
import contextlib
|
||||
import json
|
||||
import functools
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
@ -127,6 +130,13 @@ def daemonize(stdin='/dev/null', stdout='/dev/null', stderr='/dev/null'):
|
||||
os.dup2(stdout.fileno(), sys.stdout.fileno())
|
||||
os.dup2(stderr.fileno(), sys.stderr.fileno())
|
||||
|
||||
# write a pidfile
|
||||
pidfile = '/var/run/metadata.pid'
|
||||
atexit.register(functools.partial(os.remove, pidfile))
|
||||
pid = str(os.getpid())
|
||||
with contextlib.closing(open(pidfile, 'w+')) as f:
|
||||
f.write("%s\n" % pid)
|
||||
|
||||
|
||||
def _fork():
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user