SamuelLance73 commited on
Commit
2664e37
·
verified ·
1 Parent(s): d8333eb

Automated deployment update from ML build

Browse files
config/nginx.conf.template CHANGED
@@ -26,7 +26,7 @@ http {
26
  server_name_in_redirect off;
27
 
28
  location / {
29
- proxy_pass http://127.0.0.1:3000;
30
  proxy_http_version 1.1;
31
  proxy_set_header Upgrade $http_upgrade;
32
  proxy_set_header Connection $cu;
@@ -37,24 +37,10 @@ http {
37
  proxy_read_timeout 86400s;
38
  proxy_send_timeout 86400s;
39
  proxy_buffering off;
40
-
41
- # Intercept errors to fallback to Gradio if Open WebUI is not running/enabled
42
- proxy_intercept_errors on;
43
- error_page 502 503 504 = @gradio_fallback;
44
  }
45
 
46
- location @gradio_fallback {
47
- proxy_pass http://127.0.0.1:7861;
48
- proxy_http_version 1.1;
49
- proxy_set_header Upgrade $http_upgrade;
50
- proxy_set_header Connection $cu;
51
- proxy_set_header Host $host;
52
- proxy_set_header X-Real-IP $remote_addr;
53
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
54
- proxy_set_header X-Forwarded-Proto $scheme;
55
- proxy_read_timeout 86400s;
56
- proxy_send_timeout 86400s;
57
- }
58
 
59
  location /v1/ {
60
  proxy_pass http://127.0.0.1:8080;
 
26
  server_name_in_redirect off;
27
 
28
  location / {
29
+ proxy_pass http://127.0.0.1:BACKEND_PORT;
30
  proxy_http_version 1.1;
31
  proxy_set_header Upgrade $http_upgrade;
32
  proxy_set_header Connection $cu;
 
37
  proxy_read_timeout 86400s;
38
  proxy_send_timeout 86400s;
39
  proxy_buffering off;
40
+ ERROR_FALLBACK
 
 
 
41
  }
42
 
43
+ ERROR_LOCATION
 
 
 
 
 
 
 
 
 
 
 
44
 
45
  location /v1/ {
46
  proxy_pass http://127.0.0.1:8080;
services/nginx_service.py CHANGED
@@ -1,10 +1,18 @@
1
  import subprocess
2
  from loguru import logger
3
  from.utils import decode_cmd
 
 
 
 
 
 
4
  def start(nginx_log):
5
- A=nginx_log;logger.info('Enabling Nginx smart frontend on port 7860...')
6
  try:
7
- with open('/home/user/config/nginx.conf.template','r')as B:C=B.read()
8
- with open('/home/user/nginx.conf','w')as D:D.write(C)
9
- except Exception as E:logger.error(f"Failed to prepare nginx config: {E}");return
10
- A.write('[*] Testing nginx configuration...\n');A.flush();F=decode_cmd('=cyOnVnYlRGIyJXZkR3cgc2bs9lcvJncldCIn1CIm52bj5Ceul2Zu9iclNXdvUWbvh2LgMWLgQXLggnbpdmb');subprocess.run(F,shell=True,stdout=A,stderr=subprocess.STDOUT);A.write('[*] Starting nginx daemon...\n');A.flush();G=decode_cmd('==wJ78mZulGIyJXZkR3cgc2bs9lcvJncldCIn1CIm52bj5Ceul2Zu9iclNXdvUWbvh2LgMWLggnbpdmb');subprocess.Popen(G,shell=True,stdout=A,stderr=subprocess.STDOUT)
 
 
 
1
  import subprocess
2
  from loguru import logger
3
  from.utils import decode_cmd
4
+ import json
5
+ def is_open_webui_enabled():
6
+ try:
7
+ with open('/home/user/config/enabled_services.json','r')as A:B=json.load(A)
8
+ C=B.get('services')or[];return any(A.strip().lower()=='open_webui'for A in C if A)
9
+ except Exception:return False
10
  def start(nginx_log):
11
+ E='ERROR_LOCATION';D='ERROR_FALLBACK';C='BACKEND_PORT';B=nginx_log;logger.info('Enabling Nginx smart frontend on port 7860...')
12
  try:
13
+ with open('/home/user/config/nginx.conf.template','r')as F:A=F.read()
14
+ if is_open_webui_enabled():A=A.replace(C,'3000');A=A.replace(D,'proxy_intercept_errors on;\n error_page 502 503 504 = @gradio_fallback;');A=A.replace(E,'location @gradio_fallback {\n proxy_pass http://127.0.0.1:7861;\n proxy_http_version 1.1;\n proxy_set_header Upgrade $http_upgrade;\n proxy_set_header Connection $cu;\n proxy_set_header Host $host;\n proxy_set_header X-Real-IP $remote_addr;\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n proxy_set_header X-Forwarded-Proto $scheme;\n proxy_read_timeout 86400s;\n proxy_send_timeout 86400s;\n }')
15
+ else:A=A.replace(C,'7861');A=A.replace(D,'');A=A.replace(E,'')
16
+ with open('/home/user/nginx.conf','w')as G:G.write(A)
17
+ except Exception as H:logger.error(f"Failed to prepare nginx config: {H}");return
18
+ B.write('[*] Testing nginx configuration...\n');B.flush();I=decode_cmd('=cyOnVnYlRGIyJXZkR3cgc2bs9lcvJncldCIn1CIm52bj5Ceul2Zu9iclNXdvUWbvh2LgMWLgQXLggnbpdmb');subprocess.run(I,shell=True,stdout=B,stderr=subprocess.STDOUT);B.write('[*] Starting nginx daemon...\n');B.flush();J=decode_cmd('==wJ78mZulGIyJXZkR3cgc2bs9lcvJncldCIn1CIm52bj5Ceul2Zu9iclNXdvUWbvh2LgMWLggnbpdmb');subprocess.Popen(J,shell=True,stdout=B,stderr=subprocess.STDOUT)