force rewrited code
This commit is contained in:
98
launcher.py
98
launcher.py
@@ -4,6 +4,7 @@ import os
|
||||
import sys
|
||||
import time
|
||||
import webbrowser
|
||||
import shutil
|
||||
|
||||
|
||||
def install_missing_packages():
|
||||
@@ -17,6 +18,62 @@ def install_missing_packages():
|
||||
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
|
||||
|
||||
|
||||
def check_node_js():
|
||||
"""Sprawdź czy Node.js jest zainstalowany"""
|
||||
return shutil.which("node") is not None and shutil.which("npm") is not None
|
||||
|
||||
|
||||
def run_backend_only():
|
||||
"""Uruchom tylko backend"""
|
||||
base_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
backend_dir = os.path.join(base_dir, "backend", "app")
|
||||
|
||||
print("\n" + "="*60)
|
||||
print(" ARCHIVIUM - Backend Only Mode")
|
||||
print("="*60 + "\n")
|
||||
|
||||
print("[*] Startuje backend FastAPI na porcie 8000...")
|
||||
print("[*] Czekaj 2-3 sekundy na zainicjalizowanie...\n")
|
||||
|
||||
backend_process = subprocess.Popen(
|
||||
[sys.executable, "main.py"],
|
||||
cwd=backend_dir
|
||||
)
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
print("\n" + "="*60)
|
||||
print("✓ Backend uruchomiony!")
|
||||
print("="*60)
|
||||
print("\n📡 API dostępne:")
|
||||
print(" http://localhost:8000/api/status")
|
||||
print(" http://localhost:8000/docs (Swagger UI)")
|
||||
print("\n🔧 Testy API:")
|
||||
print(" curl http://localhost:8000/api/status")
|
||||
print(" curl -X POST http://localhost:8000/api/init \\")
|
||||
print(" -H 'Content-Type: application/json' \\")
|
||||
print(" -d '{\"password\": \"TestPassword123\"}'")
|
||||
print("\n❌ Frontend nie dostępny (Node.js nie zainstalowany)")
|
||||
print("\n📝 Aby zainstalować Node.js na Fedora Atomic:")
|
||||
print(" 1. Za pomocą toolbox:")
|
||||
print(" toolbox create")
|
||||
print(" toolbox run sudo dnf install nodejs npm")
|
||||
print(" 2. Za pomocą brew:")
|
||||
print(" brew install node")
|
||||
print(" 3. Lub pobrać z https://nodejs.org/")
|
||||
print("\n Po instalacji Node.js, uruchom:")
|
||||
print(" cd frontend && npm install && npm start")
|
||||
print("\nAby zatrzymać backend: Ctrl+C\n")
|
||||
|
||||
try:
|
||||
backend_process.wait()
|
||||
except KeyboardInterrupt:
|
||||
print("\n[*] Zatrzymywanie backendu...")
|
||||
backend_process.terminate()
|
||||
backend_process.wait()
|
||||
print("[✓] Backend zatrzymany")
|
||||
|
||||
|
||||
def run_archivium():
|
||||
"""Uruchom całą aplikację Archivium"""
|
||||
install_missing_packages()
|
||||
@@ -25,6 +82,23 @@ def run_archivium():
|
||||
backend_dir = os.path.join(base_dir, "backend", "app")
|
||||
frontend_dir = os.path.join(base_dir, "frontend")
|
||||
|
||||
# Sprawdź czy Node.js jest dostępny
|
||||
has_node = check_node_js()
|
||||
|
||||
if not has_node:
|
||||
print("\n⚠️ Node.js/npm nie znaleziony!")
|
||||
print("\nOpcje:")
|
||||
print("1. Uruchomić tylko backend (Enter)")
|
||||
print("2. Wyjść i zainstalować Node.js (q)\n")
|
||||
choice = input("Wybór [1/q]: ").strip().lower()
|
||||
|
||||
if choice == 'q':
|
||||
print("[*] Wyjście. Zainstaluj Node.js i uruchom ponownie.")
|
||||
sys.exit(1)
|
||||
else:
|
||||
run_backend_only()
|
||||
return
|
||||
|
||||
print("\n" + "="*50)
|
||||
print(" ARCHIVIUM - System Zarządzania Archiwum")
|
||||
print("="*50 + "\n")
|
||||
@@ -36,16 +110,11 @@ def run_archivium():
|
||||
)
|
||||
|
||||
print("[2/3] Startuje frontend (Port 3000)...")
|
||||
try:
|
||||
frontend_process = subprocess.Popen(
|
||||
"npm start",
|
||||
shell=True,
|
||||
cwd=frontend_dir,
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"[!] Uwaga: Nie udało się uruchomić frontendu: {e}")
|
||||
print("[*] Frontend może wymagać: npm install && npm start")
|
||||
frontend_process = None
|
||||
frontend_process = subprocess.Popen(
|
||||
"npm start",
|
||||
shell=True,
|
||||
cwd=frontend_dir,
|
||||
)
|
||||
|
||||
print("[3/3] Otwieranie przeglądarki...")
|
||||
time.sleep(3)
|
||||
@@ -66,16 +135,13 @@ def run_archivium():
|
||||
|
||||
try:
|
||||
backend_process.wait()
|
||||
if frontend_process:
|
||||
frontend_process.wait()
|
||||
frontend_process.wait()
|
||||
except KeyboardInterrupt:
|
||||
print("\n[*] Zatrzymywanie systemu...")
|
||||
backend_process.terminate()
|
||||
if frontend_process:
|
||||
frontend_process.terminate()
|
||||
frontend_process.terminate()
|
||||
backend_process.wait()
|
||||
if frontend_process:
|
||||
frontend_process.wait()
|
||||
frontend_process.wait()
|
||||
print("[✓] System zatrzymany")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user