diff --git a/bin/gunicorn_paste b/bin/gunicorn_paste index 524f3850..1703893d 100644 --- a/bin/gunicorn_paste +++ b/bin/gunicorn_paste @@ -63,12 +63,16 @@ def get_app(parser, opts, args): else: workers = int(ctx.local_conf.get('workers', 1)) + opts.host = opts.host or ctx.local_conf.get('host', '127.0.0.1') + opts.port = opts.port or int(ctx.local_conf.get('port', 8000)) + debug = ctx.global_conf.get('debug') == "true" if debug: # we force to one worker in debug mode. workers = 1 opts.workers=workers + app = loadapp(config_url, relative_to=relative_to) return app diff --git a/gunicorn/arbiter.py b/gunicorn/arbiter.py index 19f9fa74..e4eee544 100644 --- a/gunicorn/arbiter.py +++ b/gunicorn/arbiter.py @@ -92,6 +92,8 @@ class Arbiter(object): if i < 5: self.log.error("Retrying in 1 second.") time.sleep(1) + if self.LISTENER: + self.log.info("Listen on %s:%s" % self.LISTENER.getsockname()) def init_socket_fromfd(self, fd, address): sock = socket.fromfd(fd, socket.AF_INET, socket.SOCK_STREAM) diff --git a/gunicorn/main.py b/gunicorn/main.py index 52ced03f..6c103ca9 100644 --- a/gunicorn/main.py +++ b/gunicorn/main.py @@ -19,9 +19,9 @@ LOG_LEVELS = { def options(): return [ - op.make_option('--host', dest='host', default='127.0.0.1', + op.make_option('--host', dest='host', help='Host to listen on. [%default]'), - op.make_option('--port', dest='port', default=8000, type='int', + op.make_option('--port', dest='port', type='int', help='Port to listen on. [%default]'), op.make_option('--workers', dest='workers', type='int', help='Number of workers to spawn. [%default]'), @@ -57,8 +57,17 @@ def main(usage, get_app): workers = opts.workers or 1 if opts.debug: workers = 1 + + host = opts.host or '127.0.0.1' + port = opts.port + if port is None: + if ':' in host: + host, port = host.split(':', 1) + port = int(port) + else: + port = 8000 - arbiter = Arbiter((opts.host, opts.port), workers, app, + arbiter = Arbiter((host,port), workers, app, opts.debug) arbiter.run()