Initial commit
Dieser Commit ist enthalten in:
141
.cleanup-backup/main-windows.py
Normale Datei
141
.cleanup-backup/main-windows.py
Normale Datei
@ -0,0 +1,141 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
SkillMate - Windows-optimierter Haupteinstiegspunkt
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import time
|
||||
import webbrowser
|
||||
import signal
|
||||
import atexit
|
||||
from pathlib import Path
|
||||
|
||||
class SkillMateStarter:
|
||||
def __init__(self):
|
||||
self.processes = []
|
||||
self.base_dir = Path(__file__).parent.absolute()
|
||||
|
||||
# Registriere Cleanup-Handler
|
||||
atexit.register(self.cleanup)
|
||||
if sys.platform != 'win32':
|
||||
signal.signal(signal.SIGINT, self.signal_handler)
|
||||
signal.signal(signal.SIGTERM, self.signal_handler)
|
||||
|
||||
def signal_handler(self, signum, frame):
|
||||
"""Handle Strg+C und andere Signale"""
|
||||
print("\n\n🛑 SkillMate wird beendet...")
|
||||
self.cleanup()
|
||||
sys.exit(0)
|
||||
|
||||
def cleanup(self):
|
||||
"""Beende alle gestarteten Prozesse"""
|
||||
for process in self.processes:
|
||||
try:
|
||||
if process.poll() is None: # Prozess läuft noch
|
||||
if sys.platform == 'win32':
|
||||
subprocess.call(['taskkill', '/F', '/T', '/PID', str(process.pid)],
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL)
|
||||
else:
|
||||
process.terminate()
|
||||
process.wait(timeout=5)
|
||||
except:
|
||||
pass
|
||||
|
||||
def check_node_npm(self):
|
||||
"""Prüfe ob Node.js und npm installiert sind"""
|
||||
try:
|
||||
# Windows-spezifische Prüfung
|
||||
if sys.platform == 'win32':
|
||||
subprocess.run(["node", "--version"],
|
||||
capture_output=True,
|
||||
check=True,
|
||||
shell=True)
|
||||
subprocess.run(["npm", "--version"],
|
||||
capture_output=True,
|
||||
check=True,
|
||||
shell=True)
|
||||
else:
|
||||
subprocess.run(["node", "--version"], capture_output=True, check=True)
|
||||
subprocess.run(["npm", "--version"], capture_output=True, check=True)
|
||||
return True
|
||||
except (subprocess.CalledProcessError, FileNotFoundError):
|
||||
print("❌ Node.js und npm müssen installiert sein!")
|
||||
print(" Bitte installieren Sie Node.js von: https://nodejs.org/")
|
||||
return False
|
||||
|
||||
def start_services_windows(self):
|
||||
"""Starte alle Services in Windows mit separaten CMD-Fenstern"""
|
||||
print("🚀 Starte SkillMate Services...")
|
||||
|
||||
# Backend
|
||||
backend_cmd = f'cd /d "{self.base_dir}\\backend" && npm run dev'
|
||||
subprocess.Popen(['cmd', '/c', f'start "SkillMate Backend" cmd /k {backend_cmd}'])
|
||||
|
||||
# Warte bis Backend bereit ist
|
||||
print(" Warte auf Backend...")
|
||||
time.sleep(5)
|
||||
|
||||
# Frontend
|
||||
frontend_cmd = f'cd /d "{self.base_dir}\\frontend" && npm run dev'
|
||||
subprocess.Popen(['cmd', '/c', f'start "SkillMate Frontend" cmd /k {frontend_cmd}'])
|
||||
|
||||
# Admin Panel (optional)
|
||||
admin_dir = self.base_dir / "admin-panel"
|
||||
if admin_dir.exists():
|
||||
admin_cmd = f'cd /d "{admin_dir}" && npm run dev -- --port 5174'
|
||||
subprocess.Popen(['cmd', '/c', f'start "SkillMate Admin" cmd /k {admin_cmd}'])
|
||||
|
||||
print("\n✨ SkillMate läuft!")
|
||||
print("\n📍 Zugriff:")
|
||||
print(" - Frontend: http://localhost:5173")
|
||||
print(" - Backend: http://localhost:3001")
|
||||
print(" - Admin: http://localhost:5174")
|
||||
|
||||
# Öffne Frontend im Browser
|
||||
time.sleep(3)
|
||||
webbrowser.open("http://localhost:5173")
|
||||
|
||||
print("\n⚡ Schließen Sie dieses Fenster, um SkillMate zu beenden")
|
||||
|
||||
|
||||
def run(self):
|
||||
"""Hauptausführungsmethode"""
|
||||
print("🎯 SkillMate wird gestartet...\n")
|
||||
|
||||
# Prüfe Voraussetzungen
|
||||
if not self.check_node_npm():
|
||||
return False
|
||||
|
||||
# Windows-spezifischer Start
|
||||
if sys.platform == 'win32':
|
||||
self.start_services_windows()
|
||||
# Halte das Hauptfenster offen
|
||||
try:
|
||||
input("\nDrücken Sie Enter zum Beenden...")
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
else:
|
||||
print("❌ Dieses Skript ist für Windows optimiert.")
|
||||
print(" Nutzen Sie 'python main.py' für andere Systeme.")
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def main():
|
||||
"""Haupteinstiegspunkt"""
|
||||
starter = SkillMateStarter()
|
||||
|
||||
try:
|
||||
success = starter.run()
|
||||
if not success:
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(f"\n❌ Unerwarteter Fehler: {e}")
|
||||
starter.cleanup()
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren