-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
executable file
·67 lines (57 loc) · 2.04 KB
/
Copy pathrun.py
File metadata and controls
executable file
·67 lines (57 loc) · 2.04 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
#!/usr/bin/env python3
"""
Quick production runner for DataOrb
Builds frontend and starts integrated Flask server
"""
import os
import subprocess
import sys
from pathlib import Path
def run_command(cmd, cwd=None):
"""Run a command and wait for completion"""
print(f"Running: {' '.join(cmd)}")
try:
result = subprocess.run(cmd, cwd=cwd, check=True)
return result.returncode == 0
except subprocess.CalledProcessError as e:
print(f"Error running command: {e}")
return False
def main():
# Ensure we're in the right directory
script_dir = Path(__file__).parent
os.chdir(script_dir)
print("🚀 DataOrb Quick Production Run")
print("=" * 40)
# Build frontend
print("🔨 Building React frontend...")
if not run_command(["npm", "run", "build"], cwd="frontend"):
print("❌ Frontend build failed!")
sys.exit(1)
print("✅ Frontend built successfully!")
# Check for virtual environment
venv_path = Path("backend/venv")
if not venv_path.exists():
print("🔧 Creating virtual environment...")
if not run_command(["python3", "-m", "venv", "venv"], cwd="backend"):
print("❌ Failed to create virtual environment!")
sys.exit(1)
# Install dependencies
print("📦 Installing dependencies...")
pip_cmd = ["backend/venv/bin/pip", "install", "-r", "backend/requirements.txt"]
if not run_command(pip_cmd):
print("❌ Failed to install dependencies!")
sys.exit(1)
# Start the server
print("🌶️ Starting integrated Flask server...")
print("🌐 Server will be available at: http://localhost:5000")
print("💡 Press Ctrl+C to stop")
try:
python_cmd = ["backend/venv/bin/python3", "backend/app.py"]
subprocess.run(python_cmd, check=True)
except KeyboardInterrupt:
print("\n🛑 Server stopped")
except subprocess.CalledProcessError as e:
print(f"❌ Server error: {e}")
sys.exit(1)
if __name__ == "__main__":
main()