2025-05-28 22:41:06 -07:00
|
|
|
import asyncio
|
2025-09-16 00:33:51 -04:00
|
|
|
import logging
|
2025-05-28 22:41:06 -07:00
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
import typer
|
|
|
|
|
|
|
|
|
|
from skyvern.cli.console import console
|
2025-10-12 10:36:24 -07:00
|
|
|
from skyvern.utils.env_paths import resolve_backend_env_path
|
2025-05-28 22:41:06 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
async def start_services(server_only: bool = False) -> None:
|
|
|
|
|
"""Start Skyvern services in the background.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
server_only: If True, only start the server, not the UI.
|
|
|
|
|
"""
|
|
|
|
|
try:
|
|
|
|
|
# Start server in the background
|
|
|
|
|
server_process = await asyncio.create_subprocess_exec(
|
|
|
|
|
sys.executable, "-m", "skyvern.cli.commands", "run", "server"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Give server a moment to start
|
|
|
|
|
await asyncio.sleep(2)
|
|
|
|
|
|
|
|
|
|
if not server_only:
|
|
|
|
|
# Start UI in the background
|
|
|
|
|
ui_process = await asyncio.create_subprocess_exec(sys.executable, "-m", "skyvern.cli.commands", "run", "ui")
|
|
|
|
|
|
|
|
|
|
console.print("\n🎉 [bold green]Skyvern is now running![/bold green]")
|
|
|
|
|
console.print("🌐 [bold]Access the UI at:[/bold] [cyan]http://localhost:8080[/cyan]")
|
2025-10-12 10:36:24 -07:00
|
|
|
console.print(f"🔑 [bold]Your API key is in {resolve_backend_env_path()} as SKYVERN_API_KEY[/bold]")
|
2025-05-28 22:41:06 -07:00
|
|
|
|
|
|
|
|
# Wait for processes to complete (they won't unless killed)
|
|
|
|
|
if not server_only:
|
|
|
|
|
await asyncio.gather(server_process.wait(), ui_process.wait())
|
|
|
|
|
else:
|
|
|
|
|
await server_process.wait()
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
console.print(f"[bold red]Error starting services: {str(e)}[/bold red]")
|
2025-09-16 00:33:51 -04:00
|
|
|
logging.error("Startup failed", exc_info=True)
|
2025-05-28 22:41:06 -07:00
|
|
|
raise typer.Exit(1)
|