mirror of https://github.com/Aidaho12/haproxy-wi
parent
7d4478d2e6
commit
9f2a45a4d3
|
@ -251,8 +251,7 @@ def show_map(serv: str) -> str:
|
||||||
def runtime_command(serv: str, enable: str, backend: str, save: str) -> str:
|
def runtime_command(serv: str, enable: str, backend: str, save: str) -> str:
|
||||||
server_state_file = sql.get_setting('server_state_file')
|
server_state_file = sql.get_setting('server_state_file')
|
||||||
haproxy_sock = sql.get_setting('haproxy_sock')
|
haproxy_sock = sql.get_setting('haproxy_sock')
|
||||||
|
cmd = f"echo {enable} {backend} |sudo socat stdio {haproxy_sock}"
|
||||||
cmd = f'echo "{enable} {backend}" |sudo socat stdio {haproxy_sock}'
|
|
||||||
|
|
||||||
if save == "on":
|
if save == "on":
|
||||||
save_command = f'echo "show servers state" | sudo socat {haproxy_sock} stdio > {server_state_file}'
|
save_command = f'echo "show servers state" | sudo socat {haproxy_sock} stdio > {server_state_file}'
|
||||||
|
@ -260,14 +259,14 @@ def runtime_command(serv: str, enable: str, backend: str, save: str) -> str:
|
||||||
else:
|
else:
|
||||||
command = [cmd]
|
command = [cmd]
|
||||||
|
|
||||||
if enable != "show":
|
try:
|
||||||
roxywi_common.logging(serv, f'Has been {enable}ed {backend}', login=1, keep_history=1, service='haproxy')
|
output = server_mod.ssh_command(serv, command, show_log="1")
|
||||||
print(
|
except Exception as e:
|
||||||
f'<center><h3>You {enable} {backend} on HAProxy {serv}. <a href="/app/stats/haproxy/{serv}" '
|
return f'{e}'
|
||||||
f'title="View stat" target="_blank">Look it</a> or <a href="/app/runtimeapi" '
|
else:
|
||||||
f'title="Runtime API">Edit something else</a></h3><br />')
|
if enable != "show":
|
||||||
|
roxywi_common.logging(serv, f'Has been {enable}ed {backend}', login=1, keep_history=1, service='haproxy')
|
||||||
action = f'runtimeapi {enable} {backend}'
|
return f'<center><h3>You {enable} {backend} on HAProxy {serv}. <a href="/app/stats/haproxy/{serv}" ' \
|
||||||
roxywi_common.logging(serv, action)
|
f'title="View stat" target="_blank">Look it</a> or <a href="/app/runtimeapi" ' \
|
||||||
|
f'title="Runtime API">Edit something else</a></h3><br />' \
|
||||||
return server_mod.ssh_command(serv, command, show_log="1")
|
f'{output}'
|
||||||
|
|
|
@ -7,7 +7,11 @@ distro>=1.2.0
|
||||||
retry>=0.9.2
|
retry>=0.9.2
|
||||||
psutil>=5.9.1
|
psutil>=5.9.1
|
||||||
pdpyras>=4.5.2
|
pdpyras>=4.5.2
|
||||||
Flask-APScheduler>=1.12.4
|
Werkzeug==2.0.3
|
||||||
|
Flask==2.0.3
|
||||||
|
Flask-Login==0.4.1
|
||||||
|
Flask-APScheduler==1.12.4
|
||||||
|
Flask-Caching==1.10.1
|
||||||
python3-nmap<=1.5.1
|
python3-nmap<=1.5.1
|
||||||
aio-pika>=7.1.0
|
aio-pika>=7.1.0
|
||||||
pika>=1.2.0
|
pika>=1.2.0
|
||||||
|
|
Loading…
Reference in New Issue