-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.py
More file actions
executable file
·63 lines (51 loc) · 1.9 KB
/
start.py
File metadata and controls
executable file
·63 lines (51 loc) · 1.9 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
#!/usr/bin/env python3
import sys
import subprocess
import os
from pathlib import Path
def setup_venv():
# Get project root directory (script is now in root)
project_root = Path(__file__).parent
os.chdir(project_root)
venv_path = project_root / "venv"
if not venv_path.exists():
print("Creating virtual environment...")
subprocess.run([sys.executable, "-m", "venv", "venv"], check=True)
print("✓ Virtual environment created")
# Get pip path
if os.name == 'nt': # Windows
pip_path = venv_path / "Scripts" / "pip.exe"
python_path = venv_path / "Scripts" / "python.exe"
else: # Unix/Linux/macOS
pip_path = venv_path / "bin" / "pip"
python_path = venv_path / "bin" / "python"
# Install requirements
if Path("requirements.txt").exists():
print("Installing requirements...")
subprocess.run([str(pip_path), "install", "-r", "requirements.txt"], check=True)
print("✓ Requirements installed")
return python_path
def start_server():
print("Setting up Helpful Tools v2...")
try:
python_path = setup_venv()
# Create PID file
with open("helpful-tools-v2.pid", "w") as f:
f.write(str(os.getpid()))
print("\n" + "="*50)
print("🚀 Starting Helpful Tools v2")
print("📍 Server: http://127.0.0.1:8000")
print("📋 Dashboard ready with minimal setup")
print("="*50 + "\n")
# Start the Flask app
subprocess.run([str(python_path), "app.py"])
except KeyboardInterrupt:
print("\n⏹️ Server stopped by user")
except Exception as e:
print(f"❌ Error: {e}")
finally:
# Clean up PID file
if Path("helpful-tools-v2.pid").exists():
Path("helpful-tools-v2.pid").unlink()
if __name__ == "__main__":
start_server()