本文整理汇总了Python中gunicorn.app.wsgiapp.WSGIApplication方法的典型用法代码示例。如果您正苦于以下问题:Python wsgiapp.WSGIApplication方法的具体用法?Python wsgiapp.WSGIApplication怎么用?Python wsgiapp.WSGIApplication使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gunicorn.app.wsgiapp
的用法示例。
在下文中一共展示了wsgiapp.WSGIApplication方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: gunicorn_run
# 需要导入模块: from gunicorn.app import wsgiapp [as 别名]
# 或者: from gunicorn.app.wsgiapp import WSGIApplication [as 别名]
def gunicorn_run():
"""
The ``gunicorn_pecan`` command for launching ``pecan`` applications
"""
try:
from gunicorn.app.wsgiapp import WSGIApplication
except ImportError as exc:
args = exc.args
arg0 = args[0] if args else ''
arg0 += ' (are you sure `gunicorn` is installed?)'
exc.args = (arg0,) + args[1:]
raise
class PecanApplication(WSGIApplication):
def init(self, parser, opts, args):
if len(args) != 1:
parser.error("No configuration file was specified.")
self.cfgfname = os.path.normpath(
os.path.join(os.getcwd(), args[0])
)
self.cfgfname = os.path.abspath(self.cfgfname)
if not os.path.exists(self.cfgfname):
parser.error("Config file not found: %s" % self.cfgfname)
from pecan.configuration import _runtime_conf, set_config
set_config(self.cfgfname, overwrite=True)
# If available, use the host and port from the pecan config file
cfg = {}
if _runtime_conf.get('server'):
server = _runtime_conf['server']
if hasattr(server, 'host') and hasattr(server, 'port'):
cfg['bind'] = '%s:%s' % (
server.host, server.port
)
return cfg
def load(self):
from pecan.deploy import deploy
return deploy(self.cfgfname)
PecanApplication("%(prog)s [OPTIONS] config.py").run()
示例2: run
# 需要导入模块: from gunicorn.app import wsgiapp [as 别名]
# 或者: from gunicorn.app.wsgiapp import WSGIApplication [as 别名]
def run(self, *args, **kwargs):
from gunicorn.app.wsgiapp import WSGIApplication
app = WSGIApplication()
app.app_uri = 'aardvark:create_app()'
return app.run()
示例3: run_wsgi_app
# 需要导入模块: from gunicorn.app import wsgiapp [as 别名]
# 或者: from gunicorn.app.wsgiapp import WSGIApplication [as 别名]
def run_wsgi_app(address, app):
try:
from gunicorn.app.wsgiapp import WSGIApplication
class GunicornApplication(WSGIApplication):
def init(self, parser, opts, args):
return {'bind': '%s:%d' % (address[0], int(address[1])),
'workers': 2,
'worker_class': 'gevent'}
def load(self):
return application
GunicornApplication().run()
except ImportError:
from gevent.wsgi import WSGIServer
WSGIServer(address, app).serve_forever()
示例4: run
# 需要导入模块: from gunicorn.app import wsgiapp [as 别名]
# 或者: from gunicorn.app.wsgiapp import WSGIApplication [as 别名]
def run():
"""\
The ``gunicorn`` command line runner for launching Gunicorn with
generic WSGI applications.
"""
from gunicorn.app.wsgiapp import WSGIApplication
WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()