mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Added stand-alone WSGI app
This commit is contained in:
parent
6d703c9575
commit
d6c9b8c138
@ -83,10 +83,11 @@ def start():
|
||||
# Start the development server
|
||||
cherrypy.quickstart(root, '/', conf)
|
||||
else:
|
||||
# Mount and start the WSGI app using the production CherryPy server
|
||||
verify_certs(apiconf['ssl_crt'], apiconf['ssl_key'])
|
||||
from . import wsgi
|
||||
application = wsgi.get_application(root, apiopts, conf)
|
||||
|
||||
app = cherrypy.tree.mount(app, '/', config=conf)
|
||||
# Mount and start the WSGI app using the production CherryPy server
|
||||
verify_certs(apiopts['ssl_crt'], apiopts['ssl_key'])
|
||||
|
||||
ssl_a = wsgiserver.ssl_builtin.BuiltinSSLAdapter(
|
||||
apiopts['ssl_crt'], apiopts['ssl_key'])
|
||||
|
61
saltapi/netapi/rest_cherrypy/wsgi.py
Normal file
61
saltapi/netapi/rest_cherrypy/wsgi.py
Normal file
@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env python
|
||||
'''
|
||||
A WSGI app to start a REST interface to Salt
|
||||
|
||||
This WSGI app can be used with any WSGI-compliant server. See the rest_cherrypy
|
||||
netapi module to see how this app is run with the CherryPy WSGI server.
|
||||
|
||||
Apache's mod_wsgi instructions
|
||||
------------------------------
|
||||
|
||||
Add the path to this script as a WSGIScriptAlias in the Apache configuration
|
||||
for your site. For example a virtual host configuration may look something
|
||||
like::
|
||||
|
||||
<VirtualHost *:80>
|
||||
ServerName example.com
|
||||
ServerAlias *.example.com
|
||||
|
||||
ServerAdmin webmaster@example.com
|
||||
|
||||
LogLevel warn
|
||||
ErrorLog /var/www/example.com/logs/error.log
|
||||
CustomLog /var/www/example.com/logs/access.log combined
|
||||
|
||||
DocumentRoot /var/www/example.com/htdocs
|
||||
|
||||
WSGIScriptAlias / /path/to/saltapi/netapi/rest_cherrypy/app.wsgi
|
||||
</VirtualHost>
|
||||
|
||||
'''
|
||||
# pylint: disable=C0103
|
||||
|
||||
import cherrypy
|
||||
|
||||
from . import app
|
||||
|
||||
def bootstrap_app():
|
||||
'''
|
||||
Grab the opts dict of the master config by trying to import Salt
|
||||
'''
|
||||
import salt.client
|
||||
opts = salt.client.LocalClient().opts
|
||||
return app.get_app(opts)
|
||||
|
||||
def get_application(*args):
|
||||
'''
|
||||
Returns a WSGI application function. If you supply the WSGI app and config
|
||||
it will use that, otherwise it will try to obtain them from a local Salt
|
||||
installation
|
||||
'''
|
||||
opts_tuple = args
|
||||
|
||||
def wsgi_app(environ, start_response):
|
||||
root, _, conf = opts_tuple or bootstrap_app()
|
||||
|
||||
cherrypy.tree.mount(root, '/', conf)
|
||||
return cherrypy.tree(environ, start_response)
|
||||
|
||||
return wsgi_app
|
||||
|
||||
application = get_application()
|
Loading…
Reference in New Issue
Block a user