Spaces:
Paused
Paused
File size: 2,584 Bytes
3b615f3 e1479f2 3b615f3 28d6cc6 e1479f2 c4c70e3 8cefa2b d3c687c e1479f2 d3c687c c4c70e3 e1479f2 1e2ce50 e1479f2 1e2ce50 e1479f2 1e2ce50 e1479f2 1e2ce50 e1479f2 1e2ce50 e1479f2 1e2ce50 e1479f2 3b615f3 1e2ce50 3b615f3 1e2ce50 3b615f3 d3c687c 3b615f3 1e2ce50 3b615f3 1e2ce50 3b615f3 1e2ce50 3b615f3 c4c70e3 e1479f2 c4c70e3 1e2ce50 3b615f3 c4c70e3 e1479f2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
import os
import subprocess
import threading
from http.server import SimpleHTTPRequestHandler, HTTPServer
# دریافت مسیر
CURRENT_DIR = os.getcwd()
# 1. ساخت سای
html_content = """<!DOCTYPE html>
<html>
<head><title>System Status</title>
<style>body{font-family:sans-serif;text-align:center;padding:50px;background:#f0f2f5;}
.card{background:#fff;padding:30px;border-radius:12px;display:inline-block;box-shadow:0 4px 6px rgba(0,0,0,0.1);}
h1{color:#1a73e8;} .ok{color:#34a853;font-weight:bold;}</style></head>
<body><div class="card"><h1>AI Inference Node</h1>
<p>Status: <span class="ok">OPERATIONAL</span></p><p>Region: US-East-1</p></div></body></html>"""
with open("index.html", "w") as f:
f.write(html_content)
# 2. تنظیمات Ng
nginx_conf = f"""
worker_processes 1;
daemon off;
pid /tmp/nginx.pid;
error_log /dev/null;
events {{ worker_connections 1024; }}
http {{
access_log off;
client_body_temp_path /tmp/client_body;
proxy_temp_path /tmp/proxy;
fastcgi_temp_path /tmp/fastcgi;
uwsgi_temp_path /tmp/uwsgi;
scgi_temp_path /tmp/scgi;
server {{
listen 7860;
root {CURRENT_DIR};
index index.html;
location / {{
try_files $uri $uri/ =404;
}}
location /vl {{
proxy_redirect off;
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}}
}}
}}
"""
with open("nginx.conf", "w") as f:
f.write(nginx_conf)
# 3. تنظیمات Xray (روی پورت 3000)
xray_config = """
{
"log": { "loglevel": "none" },
"inbounds": [
{
"port": 3000,
"listen": "127.0.0.1",
"protocol": "vless",
"settings": {
"clients": [
{
"id": "11111111-2222-3333-4444-555555555555",
"level": 0
}
],
"decryption": "none"
},
"streamSettings": {
"network": "ws",
"wsSettings": {
"path": "/vl"
}
}
}
],
"outbounds": [{ "protocol": "freedom" }]
}
"""
with open("config.json", "w") as f:
f.write(xray_config)
# 4. اجرای سسها
print(f"Working Directory: {CURRENT_DIR}")
# اجرای ay
subprocess.Popen(["./xray", "-c", "config.json"])
# اجرای Ng
nginx_config_path = os.path.join(CURRENT_DIR, "nginx.conf")
print(f"Starting Nginx using config: {nginx_config_path}")
subprocess.run(["nginx", "-c", nginx_config_path]) |