2018-02-13 02:48:00 +00:00
|
|
|
import os
|
|
|
|
import subprocess
|
2019-02-20 04:36:43 +00:00
|
|
|
|
2018-02-13 02:48:00 +00:00
|
|
|
from flask import Flask
|
|
|
|
app = Flask(__name__)
|
2021-10-04 04:55:23 +00:00
|
|
|
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")
|
2018-02-13 02:48:00 +00:00
|
|
|
else:
|
|
|
|
config = os.path.join(app.config.get('ROOT_DIR', os.getcwd()), "config.py")
|
|
|
|
app.config.from_pyfile(config)
|
|
|
|
|
2020-12-22 04:36:29 +00:00
|
|
|
timeout = app.config['TIMEOUT']
|
2020-12-21 23:44:26 +00:00
|
|
|
|
2018-02-13 02:48:00 +00:00
|
|
|
|
|
|
|
def start_websockify(websockify_path, target_file):
|
|
|
|
result = subprocess.run(['pgrep', 'websockify'], stdout=subprocess.PIPE)
|
|
|
|
if not result.stdout:
|
Update VNC functionality for Proxmox 7 (#148)
Chown `targets`, Add run and kill scripts
Lol Joe figured it out
* Dude it works holy shit
We need to fix some logistical bugs, probably, and also like remove dead
code lol
* Open VNC session on the node that the VM belongs
Figured out why I couldn't open a session on anything but 01. It was
because I was making the API call on proxmox01-nrh. So that's where the
session opened. I hope that by doing this, it will balance the load
(what little there is) from VNC sessions.
* Update websockify-related tasks
* Remove SSH key from build
* Add option to specify VNC port.
Should be 443 for OKD, probably 8081 for development.
This hosts a smattering of fixes, acutally uses gunicorn properly(?),
launches websockify correctly, and introduces MORE DEAD CODE!
TODO: Fix the scheduling system
* Make things not crash as much :)
* Remove obviously dead code
There's still some code in here that may require more careful
extraction, testing, and review, so I'm saving that for another PR.
* Fix Joe's complaints
* Replace hardcoded URL
2022-07-30 00:56:00 +00:00
|
|
|
print("Websockify is stopped. Starting websockify.")
|
2022-09-01 04:04:38 +00:00
|
|
|
proxstar_port = app.config.get('WEBSOCKIFY_PORT')
|
2020-12-21 23:44:26 +00:00
|
|
|
subprocess.call(
|
|
|
|
[
|
|
|
|
websockify_path,
|
2022-09-01 00:20:21 +00:00
|
|
|
proxstar_port,
|
2020-12-21 23:44:26 +00:00
|
|
|
'--token-plugin',
|
|
|
|
'TokenFile',
|
|
|
|
'--token-source',
|
|
|
|
target_file,
|
|
|
|
'-D',
|
|
|
|
],
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
)
|
Update VNC functionality for Proxmox 7 (#148)
Chown `targets`, Add run and kill scripts
Lol Joe figured it out
* Dude it works holy shit
We need to fix some logistical bugs, probably, and also like remove dead
code lol
* Open VNC session on the node that the VM belongs
Figured out why I couldn't open a session on anything but 01. It was
because I was making the API call on proxmox01-nrh. So that's where the
session opened. I hope that by doing this, it will balance the load
(what little there is) from VNC sessions.
* Update websockify-related tasks
* Remove SSH key from build
* Add option to specify VNC port.
Should be 443 for OKD, probably 8081 for development.
This hosts a smattering of fixes, acutally uses gunicorn properly(?),
launches websockify correctly, and introduces MORE DEAD CODE!
TODO: Fix the scheduling system
* Make things not crash as much :)
* Remove obviously dead code
There's still some code in here that may require more careful
extraction, testing, and review, so I'm saving that for another PR.
* Fix Joe's complaints
* Replace hardcoded URL
2022-07-30 00:56:00 +00:00
|
|
|
else:
|
|
|
|
print("Websockify started.")
|
2018-02-13 02:48:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
def on_starting(server):
|
Update VNC functionality for Proxmox 7 (#148)
Chown `targets`, Add run and kill scripts
Lol Joe figured it out
* Dude it works holy shit
We need to fix some logistical bugs, probably, and also like remove dead
code lol
* Open VNC session on the node that the VM belongs
Figured out why I couldn't open a session on anything but 01. It was
because I was making the API call on proxmox01-nrh. So that's where the
session opened. I hope that by doing this, it will balance the load
(what little there is) from VNC sessions.
* Update websockify-related tasks
* Remove SSH key from build
* Add option to specify VNC port.
Should be 443 for OKD, probably 8081 for development.
This hosts a smattering of fixes, acutally uses gunicorn properly(?),
launches websockify correctly, and introduces MORE DEAD CODE!
TODO: Fix the scheduling system
* Make things not crash as much :)
* Remove obviously dead code
There's still some code in here that may require more careful
extraction, testing, and review, so I'm saving that for another PR.
* Fix Joe's complaints
* Replace hardcoded URL
2022-07-30 00:56:00 +00:00
|
|
|
print("Booting Websockify server in daemon mode...")
|
2020-12-21 23:44:26 +00:00
|
|
|
start_websockify(app.config['WEBSOCKIFY_PATH'], app.config['WEBSOCKIFY_TARGET_FILE'])
|