mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
s/app_name/proc_name. Update faq to say that you can set the
process_name in conf.
This commit is contained in:
parent
5ff4b30c28
commit
85c773098c
@ -70,7 +70,7 @@ $ kill -TTOUT $masterpid
|
|||||||
<dd>By default <tt class="docutils literal">SCRIPT_NAME</tt> is an empy string. The value could be set by
|
<dd>By default <tt class="docutils literal">SCRIPT_NAME</tt> is an empy string. The value could be set by
|
||||||
setting <tt class="docutils literal">SCRIPT_NAME</tt> in the environment or as an HTTP header.</dd>
|
setting <tt class="docutils literal">SCRIPT_NAME</tt> in the environment or as an HTTP header.</dd>
|
||||||
<dt>How to name processes?</dt>
|
<dt>How to name processes?</dt>
|
||||||
<dd>You need to install the Python package <a class="reference external" href="http://pypi.python.org/pypi/setproctitle">setproctitle</a>. Then you can name your process with <cite>-n</cite> or just let the default.</dd>
|
<dd>You need to install the Python package <a class="reference external" href="http://pypi.python.org/pypi/setproctitle">setproctitle</a>. Then you can name your process with <cite>-n</cite> or just let the default. If you use a configuration file you can set the process name with the proc_name option.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -25,4 +25,4 @@ How do I set SCRIPT_NAME?
|
|||||||
setting ``SCRIPT_NAME`` in the environment or as an HTTP header.
|
setting ``SCRIPT_NAME`` in the environment or as an HTTP header.
|
||||||
|
|
||||||
How to name processes?
|
How to name processes?
|
||||||
You need to install the Python package `setproctitle <http://pypi.python.org/pypi/setproctitle>`_. Then you can name your process with `-n` or just let the default.
|
You need to install the Python package `setproctitle <http://pypi.python.org/pypi/setproctitle>`_. Then you can name your process with `-n` or just let the default. If you use a configuration file you can set the process name with the proc_name option.
|
||||||
@ -56,7 +56,7 @@ class Arbiter(object):
|
|||||||
self.conf = kwargs.get("config", {})
|
self.conf = kwargs.get("config", {})
|
||||||
self._pidfile = None
|
self._pidfile = None
|
||||||
self.master_name = "Master"
|
self.master_name = "Master"
|
||||||
self.app_name = self.conf['app_name']
|
self.proc_name = self.conf['proc_name']
|
||||||
|
|
||||||
# get current path, try to use PWD env first
|
# get current path, try to use PWD env first
|
||||||
try:
|
try:
|
||||||
@ -162,7 +162,7 @@ class Arbiter(object):
|
|||||||
def run(self):
|
def run(self):
|
||||||
""" main master loop. Launch to start the master"""
|
""" main master loop. Launch to start the master"""
|
||||||
self.start()
|
self.start()
|
||||||
util._setproctitle("master [%s]" % self.app_name)
|
util._setproctitle("master [%s]" % self.proc_name)
|
||||||
self.manage_workers()
|
self.manage_workers()
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
@ -369,7 +369,7 @@ class Arbiter(object):
|
|||||||
# Process Child
|
# Process Child
|
||||||
worker_pid = os.getpid()
|
worker_pid = os.getpid()
|
||||||
try:
|
try:
|
||||||
util._setproctitle("worker [%s]" % self.app_name)
|
util._setproctitle("worker [%s]" % self.proc_name)
|
||||||
self.log.debug("Worker %s booting" % worker_pid)
|
self.log.debug("Worker %s booting" % worker_pid)
|
||||||
self.conf.after_fork(self, worker)
|
self.conf.after_fork(self, worker)
|
||||||
worker.run()
|
worker.run()
|
||||||
|
|||||||
@ -13,7 +13,7 @@ from gunicorn import util
|
|||||||
class Config(object):
|
class Config(object):
|
||||||
|
|
||||||
DEFAULTS = dict(
|
DEFAULTS = dict(
|
||||||
app_name = os.getcwd(),
|
proc_name = os.getcwd(),
|
||||||
bind='127.0.0.1:8000',
|
bind='127.0.0.1:8000',
|
||||||
daemon=False,
|
daemon=False,
|
||||||
debug=False,
|
debug=False,
|
||||||
|
|||||||
@ -42,7 +42,7 @@ def options():
|
|||||||
help="Change worker user"),
|
help="Change worker user"),
|
||||||
op.make_option('-g', '--group', dest="group",
|
op.make_option('-g', '--group', dest="group",
|
||||||
help="Change worker group"),
|
help="Change worker group"),
|
||||||
op.make_option('-n', '--name', dest='app_name',
|
op.make_option('-n', '--name', dest='proc_name',
|
||||||
help="Process name"),
|
help="Process name"),
|
||||||
op.make_option('--log-level', dest='loglevel',
|
op.make_option('--log-level', dest='loglevel',
|
||||||
help='Log level below which to silence messages. [info]'),
|
help='Log level below which to silence messages. [info]'),
|
||||||
@ -142,8 +142,8 @@ def paste_server(app, global_conf=None, host="127.0.0.1", port=None,
|
|||||||
if key == "debug":
|
if key == "debug":
|
||||||
value = (value == "true")
|
value = (value == "true")
|
||||||
options[key] = value
|
options[key] = value
|
||||||
if not 'app_name' in options:
|
if not 'proc_name' in options:
|
||||||
options['app_name'] = options['__file__']
|
options['proc_name'] = options['__file__']
|
||||||
|
|
||||||
conf = Config(options)
|
conf = Config(options)
|
||||||
arbiter = Arbiter(conf.address, conf.workers, app, debug=conf["debug"],
|
arbiter = Arbiter(conf.address, conf.workers, app, debug=conf["debug"],
|
||||||
@ -164,8 +164,8 @@ def run():
|
|||||||
if len(args) != 1:
|
if len(args) != 1:
|
||||||
parser.error("No application module specified.")
|
parser.error("No application module specified.")
|
||||||
|
|
||||||
if not opts.app_name:
|
if not opts.proc_name:
|
||||||
opts.app_name = args[0]
|
opts.proc_name = args[0]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return util.import_app(args[0])
|
return util.import_app(args[0])
|
||||||
@ -210,8 +210,8 @@ def run_django():
|
|||||||
settings_modname = '%s.%s' % (project_name, settings_name)
|
settings_modname = '%s.%s' % (project_name, settings_name)
|
||||||
os.environ['DJANGO_SETTINGS_MODULE'] = settings_modname
|
os.environ['DJANGO_SETTINGS_MODULE'] = settings_modname
|
||||||
|
|
||||||
if not opts.app_name:
|
if not opts.proc_name:
|
||||||
opts.app_name = settings_modname
|
opts.proc_name = settings_modname
|
||||||
|
|
||||||
# django wsgi app
|
# django wsgi app
|
||||||
return django.core.handlers.wsgi.WSGIHandler()
|
return django.core.handlers.wsgi.WSGIHandler()
|
||||||
@ -269,8 +269,8 @@ def run_paster():
|
|||||||
if not opts.debug:
|
if not opts.debug:
|
||||||
opts.debug = (ctx.global_conf.get('debug') == "true")
|
opts.debug = (ctx.global_conf.get('debug') == "true")
|
||||||
|
|
||||||
if not opts.app_name:
|
if not opts.proc_name:
|
||||||
opts.app_name = ctx.global_conf.get('__file__')
|
opts.proc_name = ctx.global_conf.get('__file__')
|
||||||
|
|
||||||
app = loadapp(config_url, relative_to=relative_to)
|
app = loadapp(config_url, relative_to=relative_to)
|
||||||
return app
|
return app
|
||||||
|
|||||||
@ -36,7 +36,7 @@ class Command(BaseCommand):
|
|||||||
help="Change worker user"),
|
help="Change worker user"),
|
||||||
make_option('-g', '--group', dest="group",
|
make_option('-g', '--group', dest="group",
|
||||||
help="Change worker group"),
|
help="Change worker group"),
|
||||||
make_option('-n', '--name', dest='app_name',
|
make_option('-n', '--name', dest='proc_name',
|
||||||
help="Process name"),
|
help="Process name"),
|
||||||
)
|
)
|
||||||
help = "Starts a fully-functional Web server using gunicorn."
|
help = "Starts a fully-functional Web server using gunicorn."
|
||||||
@ -51,8 +51,8 @@ class Command(BaseCommand):
|
|||||||
|
|
||||||
options['bind'] = addrport or '127.0.0.1'
|
options['bind'] = addrport or '127.0.0.1'
|
||||||
|
|
||||||
if not options.get('app_name'):
|
if not options.get('proc_name'):
|
||||||
options['app_name'] =settings.SETTINGS_MODULE
|
options['proc_name'] =settings.SETTINGS_MODULE
|
||||||
conf = Config(options)
|
conf = Config(options)
|
||||||
|
|
||||||
admin_media_path = options.get('admin_media_path', '')
|
admin_media_path = options.get('admin_media_path', '')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user