MCPcopy
hub / github.com/benoitc/gunicorn / serve

Function serve

gunicorn/app/pasterapp.py:32–74  ·  view source on GitHub ↗

\ A Paste Deployment server runner. Example configuration: [server:main] use = egg:gunicorn#main host = 127.0.0.1 port = 5000

(app, global_conf, **local_conf)

Source from the content-addressed store, hash-verified

30
31
32def serve(app, global_conf, **local_conf):
33 """\
34 A Paste Deployment server runner.
35
36 Example configuration:
37
38 [server:main]
39 use = egg:gunicorn#main
40 host = 127.0.0.1
41 port = 5000
42 """
43 config_file = global_conf['__file__']
44 gunicorn_config_file = local_conf.pop('config', None)
45
46 host = local_conf.pop('host', '')
47 port = local_conf.pop('port', '')
48 if host and port:
49 local_conf['bind'] = '%s:%s' % (host, port)
50 elif host:
51 local_conf['bind'] = host.split(',')
52
53 class PasterServerApplication(WSGIApplication):
54 def load_config(self):
55 self.cfg.set("default_proc_name", config_file)
56
57 if has_logging_config(config_file):
58 self.cfg.set("logconfig", config_file)
59
60 if gunicorn_config_file:
61 self.load_config_from_file(gunicorn_config_file)
62 else:
63 default_gunicorn_config_file = get_default_config_file()
64 if default_gunicorn_config_file is not None:
65 self.load_config_from_file(default_gunicorn_config_file)
66
67 for k, v in local_conf.items():
68 if v is not None:
69 self.cfg.set(k.lower(), v)
70
71 def load(self):
72 return app
73
74 PasterServerApplication().run()

Callers

nothing calls this directly

Calls 2

runMethod · 0.45

Tested by

no test coverage detected