mirror of
https://github.com/ComputerScienceHouse/proxstar.git
synced 2025-03-09 15:40:09 +00:00
start websockify once with gunicorn config
This commit is contained in:
parent
3b1740c641
commit
8e48bb1c95
3 changed files with 30 additions and 3 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,3 +3,4 @@ __pycache__/*
|
||||||
*/__pycache__/*
|
*/__pycache__/*
|
||||||
rrd/*
|
rrd/*
|
||||||
*.pyc
|
*.pyc
|
||||||
|
*_key
|
||||||
|
|
29
gunicorn_conf.py
Normal file
29
gunicorn_conf.py
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
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'])
|
|
@ -33,9 +33,6 @@ app.config["GIT_REVISION"] = subprocess.check_output(
|
||||||
with open('proxmox_ssh_key', 'w') as key:
|
with open('proxmox_ssh_key', 'w') as key:
|
||||||
key.write(app.config['PROXMOX_SSH_KEY'])
|
key.write(app.config['PROXMOX_SSH_KEY'])
|
||||||
|
|
||||||
start_websockify(app.config['WEBSOCKIFY_PATH'],
|
|
||||||
app.config['WEBSOCKIFY_TARGET_FILE'])
|
|
||||||
|
|
||||||
ssh_tunnels = []
|
ssh_tunnels = []
|
||||||
|
|
||||||
retry = 0
|
retry = 0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue