forked from ComputerScienceHouse/proxstar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgunicorn_conf.py
34 lines (27 loc) · 984 Bytes
/
gunicorn_conf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import os
import subprocess
from flask import Flask
app = Flask(__name__)
if os.path.exists(os.path.join(app.config.get('ROOT_DIR', os.getcwd()), "config.local.py")):
config = os.path.join(app.config.get('ROOT_DIR', os.getcwd()), "config.local.py")
else:
config = os.path.join(app.config.get('ROOT_DIR', os.getcwd()), "config.py")
app.config.from_pyfile(config)
timeout = app.config['TIMEOUT']
def start_websockify(websockify_path, target_file):
result = subprocess.run(['pgrep', 'websockify'], stdout=subprocess.PIPE)
if not result.stdout:
subprocess.call(
[
websockify_path,
'8081',
'--token-plugin',
'TokenFile',
'--token-source',
target_file,
'-D',
],
stdout=subprocess.PIPE,
)
def on_starting(server):
start_websockify(app.config['WEBSOCKIFY_PATH'], app.config['WEBSOCKIFY_TARGET_FILE'])