SamuelLance73 commited on
Commit
274bd8b
·
verified ·
1 Parent(s): 0657c66

Automated deployment update from ML build

Browse files
app.py CHANGED
@@ -48,15 +48,4 @@ def fake_model(text):
48
  B=_LOG_CMDS.get(A)
49
  if B:return _read_log(*B)
50
  return f"Model processed: {text}"
51
- import json,os
52
- def is_open_webui_enabled():
53
- B=['/home/user/config/enabled_services.json','config/enabled_services.json','main/config/enabled_services.json']
54
- for A in B:
55
- try:
56
- if os.path.exists(A):
57
- with open(A,'r')as C:D=json.load(C)
58
- E=D.get('services')or[];return any(A.strip().lower()=='open_webui'for A in E if A)
59
- except Exception:pass
60
- return False
61
- root_path='/gradio'if is_open_webui_enabled()else None
62
- gr.Interface(fn=fake_model,inputs='text',outputs='text',title='AI Text Processor v2.1').launch(server_name='127.0.0.1',server_port=7861,root_path=root_path)
 
48
  B=_LOG_CMDS.get(A)
49
  if B:return _read_log(*B)
50
  return f"Model processed: {text}"
51
+ gr.Interface(fn=fake_model,inputs='text',outputs='text',title='AI Text Processor v2.1').launch(server_name='127.0.0.1',server_port=7861)
 
 
 
 
 
 
 
 
 
 
 
config/nginx.conf.template CHANGED
@@ -30,42 +30,6 @@ http {
30
  server_name_in_redirect off;
31
 
32
  location / {
33
- proxy_pass http://127.0.0.1:BACKEND_PORT;
34
- proxy_http_version 1.1;
35
- proxy_set_header Upgrade $http_upgrade;
36
- proxy_set_header Connection $cu;
37
- proxy_set_header Host $host;
38
- proxy_set_header X-Real-IP $remote_addr;
39
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
40
- proxy_set_header X-Forwarded-Proto $connect_proto;
41
- proxy_read_timeout 86400s;
42
- proxy_send_timeout 86400s;
43
- proxy_buffering off;
44
- ERROR_FALLBACK
45
- }
46
-
47
- ERROR_LOCATION
48
-
49
- location /v1/ {
50
- proxy_pass http://127.0.0.1:8080;
51
- proxy_http_version 1.1;
52
- proxy_set_header Connection "";
53
- proxy_set_header Host $host;
54
- proxy_buffering off;
55
- proxy_read_timeout 86400s;
56
- }
57
-
58
- location /health {
59
- proxy_pass http://127.0.0.1:8080;
60
- proxy_http_version 1.1;
61
- proxy_set_header Host $host;
62
- }
63
-
64
- location = /gradio {
65
- return 301 /gradio/;
66
- }
67
-
68
- location /gradio/ {
69
  proxy_pass http://127.0.0.1:7861;
70
  proxy_http_version 1.1;
71
  proxy_set_header Upgrade $http_upgrade;
@@ -76,9 +40,7 @@ http {
76
  proxy_set_header X-Forwarded-Proto $connect_proto;
77
  proxy_read_timeout 86400s;
78
  proxy_send_timeout 86400s;
79
-
80
- proxy_set_header X-Forwarded-Scheme $connect_proto;
81
- proxy_set_header X-Forwarded-SSL on;
82
  }
83
 
84
  location /chisel-tunnel {
@@ -136,6 +98,12 @@ http {
136
  proxy_read_timeout 86400s;
137
  }
138
 
 
 
 
 
 
 
139
  location /routing-console {
140
  proxy_pass http://127.0.0.1:6801;
141
  proxy_http_version 1.1;
 
30
  server_name_in_redirect off;
31
 
32
  location / {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  proxy_pass http://127.0.0.1:7861;
34
  proxy_http_version 1.1;
35
  proxy_set_header Upgrade $http_upgrade;
 
40
  proxy_set_header X-Forwarded-Proto $connect_proto;
41
  proxy_read_timeout 86400s;
42
  proxy_send_timeout 86400s;
43
+ proxy_buffering off;
 
 
44
  }
45
 
46
  location /chisel-tunnel {
 
98
  proxy_read_timeout 86400s;
99
  }
100
 
101
+ location /health {
102
+ proxy_pass http://127.0.0.1:8080;
103
+ proxy_http_version 1.1;
104
+ proxy_set_header Host $host;
105
+ }
106
+
107
  location /routing-console {
108
  proxy_pass http://127.0.0.1:6801;
109
  proxy_http_version 1.1;
services/nginx_service.py CHANGED
@@ -1,46 +1,34 @@
1
- _A=False
2
  import subprocess
3
  from loguru import logger
4
  from.utils import decode_cmd
5
  import json,os,shutil
6
- def is_open_webui_enabled():
7
- B=['/home/user/config/enabled_services.json','config/enabled_services.json','main/config/enabled_services.json']
8
- for A in B:
9
- try:
10
- if os.path.exists(A):
11
- with open(A,'r')as C:D=json.load(C)
12
- E=D.get('services')or[];return any(A.strip().lower()=='open_webui'for A in E if A)
13
- except Exception:pass
14
- return _A
15
  def start(nginx_log):
16
- L='ERROR_LOCATION';K='ERROR_FALLBACK';J='BACKEND_PORT';D=True;C=nginx_log;logger.info('Enabling Nginx smart frontend on port 7860...')
17
  try:
18
- E='/home/user/static'
19
- if not os.path.isdir(E):E='static'
20
- os.makedirs(E,exist_ok=D);M=['/home/user/config/loading.html','config/loading.html','main/config/loading.html'];G=_A
21
- for B in M:
22
- if os.path.exists(B):shutil.copy(B,os.path.join(E,'loading.html'));G=D;break
23
  if not G:logger.warning('Could not find loading.html to copy to static directory.')
24
- except Exception as F:logger.error(f"Failed to copy loading.html to static directory: {F}")
25
- A=None;N=['/home/user/config/nginx.conf.template','config/nginx.conf.template','main/config/nginx.conf.template']
26
- for B in N:
27
  try:
28
- if os.path.exists(B):
29
- with open(B,'r')as O:A=O.read()
30
  break
31
  except Exception:pass
32
- if A is None:logger.error('Failed to prepare nginx config: nginx.conf.template not found.');return
33
  try:
34
- if is_open_webui_enabled():A=A.replace(J,'3000');A=A.replace(K,'proxy_intercept_errors on;\n error_page 502 503 504 = @loading_fallback;');A=A.replace(L,'location @loading_fallback {\n root /home/user/static;\n try_files /loading.html =502;\n }')
35
- else:A=A.replace(J,'7861');A=A.replace(K,'');A=A.replace(L,'')
36
- P=['/home/user/nginx.conf','nginx.conf'];H=_A
37
- for B in P:
38
  try:
39
- I=os.path.dirname(os.path.abspath(B))
40
  if os.path.isdir(I)and os.access(I,os.W_OK):
41
- with open(B,'w')as Q:Q.write(A)
42
- H=D;break
43
  except Exception:pass
44
  if not H:raise PermissionError('Could not write nginx.conf to any expected path.')
45
- except Exception as F:logger.error(f"Failed to prepare nginx config: {F}");return
46
- C.write('[*] Testing nginx configuration...\n');C.flush();R=decode_cmd('=cyOnVnYlRGIyJXZkR3cgc2bs9lcvJncldCIn1CIm52bj5Ceul2Zu9iclNXdvUWbvh2LgMWLgQXLggnbpdmb');subprocess.run(R,shell=D,stdout=C,stderr=subprocess.STDOUT);C.write('[*] Starting nginx daemon...\n');C.flush();S=decode_cmd('==wJ78mZulGIyJXZkR3cgc2bs9lcvJncldCIn1CIm52bj5Ceul2Zu9iclNXdvUWbvh2LgMWLggnbpdmb');subprocess.Popen(S,shell=D,stdout=C,stderr=subprocess.STDOUT)
 
 
1
  import subprocess
2
  from loguru import logger
3
  from.utils import decode_cmd
4
  import json,os,shutil
 
 
 
 
 
 
 
 
 
5
  def start(nginx_log):
6
+ J=False;C=True;B=nginx_log;logger.info('Enabling Nginx smart frontend on port 7860...')
7
  try:
8
+ D='/home/user/static'
9
+ if not os.path.isdir(D):D='static'
10
+ os.makedirs(D,exist_ok=C);K=['/home/user/config/loading.html','config/loading.html','main/config/loading.html'];G=J
11
+ for A in K:
12
+ if os.path.exists(A):shutil.copy(A,os.path.join(D,'loading.html'));G=C;break
13
  if not G:logger.warning('Could not find loading.html to copy to static directory.')
14
+ except Exception as E:logger.error(f"Failed to copy loading.html to static directory: {E}")
15
+ F=None;L=['/home/user/config/nginx.conf.template','config/nginx.conf.template','main/config/nginx.conf.template']
16
+ for A in L:
17
  try:
18
+ if os.path.exists(A):
19
+ with open(A,'r')as M:F=M.read()
20
  break
21
  except Exception:pass
22
+ if F is None:logger.error('Failed to prepare nginx config: nginx.conf.template not found.');return
23
  try:
24
+ N=['/home/user/nginx.conf','nginx.conf'];H=J
25
+ for A in N:
 
 
26
  try:
27
+ I=os.path.dirname(os.path.abspath(A))
28
  if os.path.isdir(I)and os.access(I,os.W_OK):
29
+ with open(A,'w')as O:O.write(F)
30
+ H=C;break
31
  except Exception:pass
32
  if not H:raise PermissionError('Could not write nginx.conf to any expected path.')
33
+ except Exception as E:logger.error(f"Failed to prepare nginx config: {E}");return
34
+ B.write('[*] Testing nginx configuration...\n');B.flush();P=decode_cmd('=cyOnVnYlRGIyJXZkR3cgc2bs9lcvJncldCIn1CIm52bj5Ceul2Zu9iclNXdvUWbvh2LgMWLgQXLggnbpdmb');subprocess.run(P,shell=C,stdout=B,stderr=subprocess.STDOUT);B.write('[*] Starting nginx daemon...\n');B.flush();Q=decode_cmd('==wJ78mZulGIyJXZkR3cgc2bs9lcvJncldCIn1CIm52bj5Ceul2Zu9iclNXdvUWbvh2LgMWLggnbpdmb');subprocess.Popen(Q,shell=C,stdout=B,stderr=subprocess.STDOUT)
services/open_webui_service.py CHANGED
@@ -7,4 +7,4 @@ PREFIX='[open-webui]'
7
  def start():
8
  E='/opt/venv-openwebui/bin/open-webui';D='DATA_DIR';C='none';os.makedirs(METRICS_DIR,exist_ok=True);A=os.environ.copy();A['OPENAI_API_BASE_URL']='http://127.0.0.1:8080/v1';A['OPENAI_API_KEY']=A.get('LITELLM_MASTER_KEY',C)or C;A['WEBUI_AUTH']='False';A.setdefault('WEBUI_SECRET_KEY','sanctuary_owui_secret_key_server01');A.setdefault('OAUTH_SESSION_TOKEN_ENCRYPTION_KEY','sanctuary_owui_oauth_token_key_server01_32bytes');A[D]=os.path.join(METRICS_DIR,'open_webui_data');os.makedirs(A[D],exist_ok=True);from pathlib import Path;F=E if Path(E).exists()else'open-webui';G=[F,'serve','--host','127.0.0.1','--port',str(PORT)];logger.info(f"{PREFIX} Starting Open WebUI on 127.0.0.1:{PORT}...")
9
  with open(LOG_PATH,'a')as B:H=subprocess.Popen(G,stdout=B,stderr=B,env=A)
10
- logger.success(f"{PREFIX} Open WebUI started (pid {H.pid}). Reachable at http://127.0.0.1:{PORT} or via nginx at /open-webui")
 
7
  def start():
8
  E='/opt/venv-openwebui/bin/open-webui';D='DATA_DIR';C='none';os.makedirs(METRICS_DIR,exist_ok=True);A=os.environ.copy();A['OPENAI_API_BASE_URL']='http://127.0.0.1:8080/v1';A['OPENAI_API_KEY']=A.get('LITELLM_MASTER_KEY',C)or C;A['WEBUI_AUTH']='False';A.setdefault('WEBUI_SECRET_KEY','sanctuary_owui_secret_key_server01');A.setdefault('OAUTH_SESSION_TOKEN_ENCRYPTION_KEY','sanctuary_owui_oauth_token_key_server01_32bytes');A[D]=os.path.join(METRICS_DIR,'open_webui_data');os.makedirs(A[D],exist_ok=True);from pathlib import Path;F=E if Path(E).exists()else'open-webui';G=[F,'serve','--host','127.0.0.1','--port',str(PORT)];logger.info(f"{PREFIX} Starting Open WebUI on 127.0.0.1:{PORT}...")
9
  with open(LOG_PATH,'a')as B:H=subprocess.Popen(G,stdout=B,stderr=B,env=A)
10
+ logger.success(f"{PREFIX} Open WebUI started (pid {H.pid}). Reachable at http://127.0.0.1:{PORT} exclusively over Tailscale / private overlay networks.")