ACCA225 commited on
Commit
4336b6e
·
verified ·
1 Parent(s): 39f43df

Update app2.py

Browse files
Files changed (1) hide show
  1. app2.py +2 -49
app2.py CHANGED
@@ -143,15 +143,7 @@ import wandb
143
  import os
144
  import time
145
  import wandb
146
- proxy_path={
147
- '/sd2/':'http://127.0.0.1:7862/',
148
- '/sd3/':'http://127.0.0.1:7863/'
149
- } # 增加一个comfyui的代理
150
- server_port=7860 # webui 默认端口
151
- _server_port = locals().get('server_port') or globals().get('server_port') or 7860
152
 
153
-
154
- _proxy_path = locals().get('proxy_path') or globals().get('proxy_path') or {}
155
  # nginx 反向代理配置文件
156
  def echoToFile(content:str,path:str):
157
  if path.find('/') >= 0:
@@ -168,48 +160,9 @@ def check_service(host, port):
168
  return False
169
  def localProxy():
170
  os.system('sudo apt install nginx -y')
171
-
172
- _proxy_path['/'] = f'http://127.0.0.1:{_server_port+1}/'
173
- _proxy_path['/1/'] = f'http://127.0.0.1:{_server_port+2}/'
174
-
175
- def getProxyLocation(subPath:str, localServer:str):
176
- return '''
177
- location '''+ subPath +'''
178
- {
179
- proxy_pass '''+ localServer +''';
180
- proxy_set_header Host $host;
181
- proxy_set_header X-Real-IP $remote_addr;
182
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
183
- proxy_set_header REMOTE-HOST $remote_addr;
184
- proxy_set_header Upgrade $http_upgrade;
185
- proxy_set_header Connection upgrade;
186
- proxy_http_version 1.1;
187
- proxy_connect_timeout 10m;
188
- proxy_read_timeout 10m;
189
- }
190
-
191
- '''
192
-
193
- conf = '''
194
- server
195
- {
196
- listen '''+str(_server_port)+''';
197
- listen [::]:'''+str(_server_port)+''';
198
- server_name 127.0.0.1 localhost 0.0.0.0 "";
199
-
200
- if ($request_method = OPTIONS) {
201
- return 200;
202
- }
203
- fastcgi_send_timeout 10m;
204
- fastcgi_read_timeout 10m;
205
- fastcgi_connect_timeout 10m;
206
-
207
- '''+ ''.join([getProxyLocation(key,_proxy_path[key]) for key in _proxy_path.keys()]) +'''
208
- }
209
- '''
210
- echoToFile(conf,'/etc/nginx/conf.d/proxy_nginx.conf')
211
  if not check_service('localhost',_server_port):
212
- run(f'''nginx -c /etc/nginx/nginx.conf''')
213
  run(f'''nginx -s reload''')
214
 
215
  # WandB登录
 
143
  import os
144
  import time
145
  import wandb
 
 
 
 
 
 
146
 
 
 
147
  # nginx 反向代理配置文件
148
  def echoToFile(content:str,path:str):
149
  if path.find('/') >= 0:
 
160
  return False
161
  def localProxy():
162
  os.system('sudo apt install nginx -y')
163
+ download_file('https://huggingface.co/datasets/ACCA225/openxlab/resolve/main/proxy_nginx.conf', os.path.join(base_directory, 'proxy_nginx.conf'))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  if not check_service('localhost',_server_port):
165
+ run(f'''nginx -c /home/xlab-app-center/stable-diffusion-webui/proxy_nginx.conf''')
166
  run(f'''nginx -s reload''')
167
 
168
  # WandB登录