-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject_start.py
More file actions
89 lines (76 loc) · 2.97 KB
/
project_start.py
File metadata and controls
89 lines (76 loc) · 2.97 KB
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
"""
اسکریپت راهاندازی کامل پروژه
"""
import subprocess
import sys
import time
import os
from pathlib import Path
from concurrent.futures import ThreadPoolExecutor
def run_backend():
"""راهاندازی backend"""
print("🚀 Starting Backend...")
os.chdir("backend")
subprocess.run([sys.executable, "start.py", "--start"])
def run_frontend():
"""راهاندازی frontend"""
print("🌐 Starting Frontend...")
os.chdir("frontend")
subprocess.run(["npm", "run", "dev"], shell=True)
def run_sing_box():
"""راهاندازی sing-box"""
print("📡 Starting sing-box...")
os.chdir("sing-box")
subprocess.run(["./sing-box.exe", "run", "-c", "hand.json"], shell=True)
def setup_backend():
"""نصب requirements backend"""
print("📦 Setting up Backend...")
os.chdir("backend")
subprocess.run([sys.executable, "start.py", "--install"])
os.chdir("..")
def setup_frontend():
"""نصب dependencies frontend"""
print("📦 Setting up Frontend...")
os.chdir("frontend")
subprocess.run(["npm", "install"], shell=True)
os.chdir("..")
def main():
"""اجرای اصلی"""
import argparse
parser = argparse.ArgumentParser(description='Project Management Script')
parser.add_argument('--setup', action='store_true', help='Setup all dependencies')
parser.add_argument('--dev', action='store_true', help='Start all services in development mode')
parser.add_argument('--backend', action='store_true', help='Start only backend')
parser.add_argument('--frontend', action='store_true', help='Start only frontend')
parser.add_argument('--sing-box', action='store_true', help='Start only sing-box')
args = parser.parse_args()
if args.setup:
print("🔧 Setting up project...")
setup_backend()
setup_frontend()
print("✅ Setup completed!")
elif args.dev:
print("🚀 Starting all services...")
with ThreadPoolExecutor(max_workers=3) as executor:
futures = []
futures.append(executor.submit(run_backend))
futures.append(executor.submit(run_frontend))
futures.append(executor.submit(run_sing_box))
# صبر برای تمام سرویسها
for future in futures:
future.result()
elif args.backend:
run_backend()
elif args.frontend:
run_frontend()
elif args.sing_box:
run_sing_box()
else:
print("استفاده:")
print(" python project_start.py --setup # نصب dependencies")
print(" python project_start.py --dev # شروع تمام سرویسها")
print(" python project_start.py --backend # فقط backend")
print(" python project_start.py --frontend # فقط frontend")
print(" python project_start.py --sing-box # فقط sing-box")
if __name__ == "__main__":
main()