pull/632/head
Mr Chen 6 months ago
parent 6246cc84d5
commit 08ac6ea08c
  1. 9
      cli.sh
  2. 8
      web/admin/__init__.py
  3. 12
      web/app.py
  4. 4
      web/setting.py

@ -59,8 +59,8 @@ mw_start_debug(){
if [ -f ${DIR}/data/port.pl ];then if [ -f ${DIR}/data/port.pl ];then
port=$(cat ${DIR}/data/port.pl) port=$(cat ${DIR}/data/port.pl)
fi fi
# gunicorn -b :${port} -k gevent -w 1 app:app cd ${DIR}/web && gunicorn -b :${port} -k eventlet -w 1 app:app
cd ${DIR}/web && gunicorn -b :${port} -k eventlet -w 1 app:app # cd ${DIR}/web && gunicorn -b :${port} -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker -w 1 app:app
} }
mw_start_panel(){ mw_start_panel(){
@ -68,8 +68,9 @@ mw_start_panel(){
if [ -f ${DIR}/data/port.pl ];then if [ -f ${DIR}/data/port.pl ];then
port=$(cat ${DIR}/data/port.pl) port=$(cat ${DIR}/data/port.pl)
fi fi
# cd ${DIR}/web && gunicorn -b :${port} -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker -w 1 app:app # cd ${DIR}/web && gunicorn -b :${port} -k eventlet -w 1 app:app
cd ${DIR}/web && gunicorn -b :${port} -k eventlet -w 1 app:app cd ${DIR}/web && gunicorn -b :${port} -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker -w 1 app:app
} }
mw_start_bgtask(){ mw_start_bgtask(){

@ -38,7 +38,9 @@ import config
import utils.config as utils_config import utils.config as utils_config
import thisdb import thisdb
# from threading import Lock
# thread = None
# thread_lock = Lock()
app = Flask(__name__, template_folder='templates/default') app = Flask(__name__, template_folder='templates/default')
@ -51,7 +53,9 @@ from whitenoise import WhiteNoise
app.wsgi_app = WhiteNoise(app.wsgi_app, root="../web/static/", prefix="static/", max_age=604800) app.wsgi_app = WhiteNoise(app.wsgi_app, root="../web/static/", prefix="static/", max_age=604800)
# session配置 # session配置
app.secret_key = uuid.UUID(int=uuid.getnode()).hex[-12:] # app.secret_key = uuid.UUID(int=uuid.getnode()).hex[-12:]
app.config['SECRET_KEY'] = uuid.UUID(int=uuid.getnode()).hex[-12:]
# app.config['sessions'] = dict() # app.config['sessions'] = dict()
app.config['SESSION_PERMANENT'] = True app.config['SESSION_PERMANENT'] = True
app.config['SESSION_USE_SIGNER'] = True app.config['SESSION_USE_SIGNER'] = True

@ -14,6 +14,13 @@ import os
from admin import app, socketio from admin import app, socketio
import config import config
from gevent.pywsgi import WSGIServer
from geventwebsocket.handler import WebSocketHandler
# from gevent import monkey
# monkey.patch_all()
if sys.version_info < (3, 6): if sys.version_info < (3, 6):
raise RuntimeError('This application must be run under Python 3.6 or later.') raise RuntimeError('This application must be run under Python 3.6 or later.')
@ -24,6 +31,11 @@ if sys.path[0] != os.path.dirname(os.path.realpath(__file__)):
# print(config.DEFAULT_SERVER,config.DEFAULT_SERVER_PORT) # print(config.DEFAULT_SERVER,config.DEFAULT_SERVER_PORT)
# app = create_app() # app = create_app()
def main(): def main():
# http_server = WSGIServer(
# (HOST, PORT), app, handler_class=WebSocketHandler)
# http_server.serve_forever()
# socketio.run(app, host=HOST, port=PORT)
socketio.run( socketio.run(
app, app,
debug=config.DEBUG, debug=config.DEBUG,

@ -57,8 +57,8 @@ threads = workers * 1
backlog = 512 backlog = 512
reload = False reload = False
daemon = True daemon = True
# worker_class = 'geventwebsocket.gunicorn.workers.GeventWebSocketWorker' worker_class = 'geventwebsocket.gunicorn.workers.GeventWebSocketWorker'
worker_class = 'eventlet' # worker_class = 'eventlet'
timeout = 600 timeout = 600
keepalive = 60 keepalive = 60
preload_app = True preload_app = True

Loading…
Cancel
Save