mirror of
https://github.com/aaPanel/aaPanel.git
synced 2026-08-28 10:49:59 +02:00
41 lines
1.5 KiB
Python
41 lines
1.5 KiB
Python
#!/usr/bin/python
|
|
#coding: utf-8
|
|
# +-------------------------------------------------------------------
|
|
# | 宝塔Linux面板
|
|
# +-------------------------------------------------------------------
|
|
# | Copyright (c) 2015-2099 宝塔软件(http://bt.cn) All rights reserved.
|
|
# +-------------------------------------------------------------------
|
|
# | Author: 黄文良 <287962566@qq.com>
|
|
# +-------------------------------------------------------------------
|
|
from gevent import monkey
|
|
monkey.patch_all()
|
|
import os,ssl
|
|
os.chdir('/www/server/panel')
|
|
from BTPanel import app,sys
|
|
|
|
if __name__ == '__main__':
|
|
f = open('data/port.pl')
|
|
PORT = int(f.read())
|
|
HOST = '0.0.0.0'
|
|
if os.path.exists('data/ipv6.pl'):
|
|
HOST = "0:0:0:0:0:0:0:0"
|
|
f.close()
|
|
|
|
#app.threaded=True
|
|
#app.jinja_env.auto_reload = True
|
|
|
|
from gevent.pywsgi import WSGIServer
|
|
from geventwebsocket.handler import WebSocketHandler
|
|
|
|
keyfile = 'ssl/privateKey.pem'
|
|
certfile = 'ssl/certificate.pem'
|
|
if os.path.exists('data/debug.pl'):
|
|
ssl_context = None
|
|
if os.path.exists('data/ssl.pl'): ssl_context=(certfile,keyfile)
|
|
app.run(host=HOST,port=PORT,threaded=True,debug=True,ssl_context=ssl_context)
|
|
else:
|
|
if os.path.exists('data/ssl.pl'):
|
|
http_server = WSGIServer((HOST, PORT), app,handler_class=WebSocketHandler,keyfile=keyfile,certfile=certfile,log=None,error_log = None)
|
|
else:
|
|
http_server = WSGIServer((HOST, PORT), app,handler_class=WebSocketHandler)
|
|
http_server.serve_forever() |