mirror of
https://github.com/DarkflameUniverse/NexusDashboard.git
synced 2024-11-21 13:07:22 +00:00
revery wsgi file for now, need to replace gunicorn
for a cross-platform solution
This commit is contained in:
parent
8012780eba
commit
4a58e963a5
16
wsgi.py
16
wsgi.py
@ -1,23 +1,19 @@
|
|||||||
from sys import platform
|
|
||||||
from app import create_app
|
from app import create_app
|
||||||
|
|
||||||
app = create_app()
|
app = create_app()
|
||||||
|
|
||||||
|
|
||||||
@app.shell_context_processor
|
@app.shell_context_processor
|
||||||
def make_shell_context():
|
def make_shell_context():
|
||||||
"""Extend the Flask shell context."""
|
"""Extend the Flask shell context."""
|
||||||
return {'app': app}
|
return {'app': app}
|
||||||
|
|
||||||
running_directly = __name__ == "wsgi" or __name__ == "__main__"
|
|
||||||
running_under_gunicorn = not running_directly and 'gunicorn' in __name__ and 'linux' in platform
|
|
||||||
|
|
||||||
# Configure development running
|
if __name__ == '__main__':
|
||||||
if running_directly:
|
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
app.run(host='0.0.0.0')
|
app.run(host='0.0.0.0')
|
||||||
|
else:
|
||||||
# Configure production running
|
|
||||||
if running_under_gunicorn:
|
|
||||||
import logging
|
import logging
|
||||||
from logging.handlers import RotatingFileHandler
|
from logging.handlers import RotatingFileHandler
|
||||||
gunicorn_logger = logging.getLogger('gunicorn.error')
|
gunicorn_logger = logging.getLogger('gunicorn.error')
|
||||||
@ -27,7 +23,3 @@ if running_under_gunicorn:
|
|||||||
file_handler.setFormatter(formatter)
|
file_handler.setFormatter(formatter)
|
||||||
app.logger.addHandler(file_handler)
|
app.logger.addHandler(file_handler)
|
||||||
app.logger.setLevel(gunicorn_logger.level)
|
app.logger.setLevel(gunicorn_logger.level)
|
||||||
|
|
||||||
# Error out if nothing has been setup
|
|
||||||
if not running_directly and not running_under_gunicorn:
|
|
||||||
raise RuntimeError('Unsupported WSGI server')
|
|
||||||
|
Loading…
Reference in New Issue
Block a user