mirror of
https://github.com/Derpy-Leggies/OnlyLegs.git
synced 2025-01-01 12:26:13 +00:00
Move Gunicorn run file to setup
This commit is contained in:
parent
7ef4a1dd91
commit
79db45f7a2
27
run.py
27
run.py
|
@ -13,36 +13,15 @@ from setup.args import PORT, ADDRESS, WORKERS, DEBUG
|
||||||
from setup.configuration import Configuration
|
from setup.configuration import Configuration
|
||||||
|
|
||||||
|
|
||||||
# Run prechecks
|
Configuration() # Run prechecks
|
||||||
Configuration()
|
|
||||||
|
|
||||||
|
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
from gallery import create_app
|
from gallery import create_app
|
||||||
|
|
||||||
create_app().run(host=ADDRESS, port=PORT, debug=True, threaded=True)
|
create_app().run(host=ADDRESS, port=PORT, debug=True, threaded=True)
|
||||||
else:
|
else:
|
||||||
from gunicorn.app.base import Application
|
from setup.runner import OnlyLegs
|
||||||
from gunicorn import util
|
|
||||||
|
|
||||||
class OnlyLegs(Application):
|
|
||||||
def __init__(self, options={}):
|
|
||||||
self.usage = None
|
|
||||||
self.callable = None
|
|
||||||
self.options = options
|
|
||||||
self.do_load_config()
|
|
||||||
|
|
||||||
def init(self, *args):
|
|
||||||
cfg = {}
|
|
||||||
for k, v in self.options.items():
|
|
||||||
if k.lower() in self.cfg.settings and v is not None:
|
|
||||||
cfg[k.lower()] = v
|
|
||||||
return cfg
|
|
||||||
|
|
||||||
def prog(self):
|
|
||||||
return 'OnlyLegs'
|
|
||||||
|
|
||||||
def load(self):
|
|
||||||
return util.import_app('gallery:create_app()')
|
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
'bind': f'{ADDRESS}:{PORT}',
|
'bind': f'{ADDRESS}:{PORT}',
|
||||||
|
|
|
@ -24,5 +24,4 @@ args = parser.parse_args()
|
||||||
PORT = args.port
|
PORT = args.port
|
||||||
ADDRESS = args.address
|
ADDRESS = args.address
|
||||||
WORKERS = args.workers
|
WORKERS = args.workers
|
||||||
|
DEBUG = args.debug
|
||||||
DEBUG = args.debug
|
|
||||||
|
|
|
@ -109,16 +109,14 @@ class Configuration:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Check if user is happy with the values
|
# Check if user is happy with the values
|
||||||
_ = input("Is this correct? (y/n): ")
|
if input("Is this correct? (y/n): ").lower() == 'y':
|
||||||
|
|
||||||
if _ == 'y' or _ == 'Y':
|
|
||||||
is_correct = True
|
is_correct = True
|
||||||
|
|
||||||
yaml_conf = {
|
yaml_conf = {
|
||||||
'admin': {
|
'admin': {
|
||||||
'name': '%s' % name,
|
'name': name,
|
||||||
'username': '%s' % username,
|
'username': username,
|
||||||
'email': '%s' % email,
|
'email': email,
|
||||||
},
|
},
|
||||||
'upload': {
|
'upload': {
|
||||||
'allowed-extensions': {
|
'allowed-extensions': {
|
||||||
|
|
22
setup/runner.py
Normal file
22
setup/runner.py
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
from gunicorn.app.base import Application
|
||||||
|
from gunicorn import util
|
||||||
|
|
||||||
|
class OnlyLegs(Application):
|
||||||
|
def __init__(self, options={}):
|
||||||
|
self.usage = None
|
||||||
|
self.callable = None
|
||||||
|
self.options = options
|
||||||
|
self.do_load_config()
|
||||||
|
|
||||||
|
def init(self, *args):
|
||||||
|
cfg = {}
|
||||||
|
for k, v in self.options.items():
|
||||||
|
if k.lower() in self.cfg.settings and v is not None:
|
||||||
|
cfg[k.lower()] = v
|
||||||
|
return cfg
|
||||||
|
|
||||||
|
def prog(self):
|
||||||
|
return 'OnlyLegs'
|
||||||
|
|
||||||
|
def load(self):
|
||||||
|
return util.import_app('gallery:create_app()')
|
Loading…
Reference in a new issue