def run_app():
from subprocess import Popen
import sys
os.chdir(os.path.abspath(os.path.dirname(__file__)))
path = os.path.join(os.path.abspath(os.path.dirname(__file__)), "manage.py")
args = [sys.executable, path, "db"]
if not os.path.exists(os.path.join(config.DATA_DIR, "plexivity.db")):
from app import db
db.create_all()
args.append("stamp")
args.append("head")
else:
args.append("upgrade")
Popen(args)
helper.startScheduler()
if config.USE_SSL:
helper.generateSSLCert()
try:
from OpenSSL import SSL
context = SSL.Context(SSL.SSLv23_METHOD)
context.use_privatekey_file(os.path.join(config.DATA_DIR, "plexivity.key"))
context.use_certificate_file(os.path.join(config.DATA_DIR, "plexivity.crt"))
app.run(host="0.0.0.0", port=config.PORT, debug=False, ssl_context=context)
except:
logger.error("plexivity should use SSL but OpenSSL was not found, starting without SSL")
app.run(host="0.0.0.0", port=config.PORT, debug=False)
else:
app.run(host="0.0.0.0", port=config.PORT, debug=False)
评论列表
文章目录