mirror of
https://github.com/Skyvern-AI/skyvern.git
synced 2026-07-09 16:09:13 +00:00
fix: quickstart fails on Windows — missing DATABASE_STRING (#5719)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
ada83abe7c
commit
8b203899e8
5 changed files with 33 additions and 12 deletions
|
|
@ -81,25 +81,20 @@ async def run_migrations_online():
|
|||
await connectable.dispose()
|
||||
|
||||
|
||||
print("Alembic mode: ", "offline" if context.is_offline_mode() else "online")
|
||||
if context.is_offline_mode():
|
||||
run_migrations_offline()
|
||||
else:
|
||||
|
||||
async def async_main():
|
||||
await run_migrations_online()
|
||||
|
||||
try:
|
||||
loop = asyncio.get_running_loop()
|
||||
except RuntimeError:
|
||||
# No running loop -> safe to start one
|
||||
print("Alembic: no running loop")
|
||||
asyncio.run(async_main())
|
||||
else:
|
||||
# Already running loop -> schedule task and await it
|
||||
print("Alembic: schedule task")
|
||||
import concurrent.futures
|
||||
|
||||
# Use a ThreadPoolExecutor to run the async function in a new thread
|
||||
with concurrent.futures.ThreadPoolExecutor() as executor:
|
||||
future = executor.submit(asyncio.run, async_main())
|
||||
future.result() # This blocks until completion
|
||||
future.result()
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ services:
|
|||
skyvern:
|
||||
image: public.ecr.aws/skyvern/skyvern:latest
|
||||
restart: on-failure
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
env_file:
|
||||
- .env
|
||||
# comment out if you want to externally call skyvern API
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ from rich.prompt import Confirm
|
|||
from skyvern.analytics import capture_setup_event
|
||||
|
||||
from .console import console
|
||||
from .llm_setup import DEFAULT_POSTGRES_DATABASE_STRING, update_or_add_env_var
|
||||
|
||||
|
||||
def command_exists(command: str) -> bool:
|
||||
|
|
@ -122,6 +123,7 @@ def setup_postgresql(no_postgres: bool = False) -> None:
|
|||
console.print("✅ [green]Database and user exist.[/green]")
|
||||
else:
|
||||
create_database_and_user()
|
||||
update_or_add_env_var("DATABASE_STRING", DEFAULT_POSTGRES_DATABASE_STRING)
|
||||
capture_setup_event("database-complete", success=True, extra_data={"source": "local"})
|
||||
return
|
||||
|
||||
|
|
@ -134,14 +136,26 @@ def setup_postgresql(no_postgres: bool = False) -> None:
|
|||
return
|
||||
|
||||
if not is_docker_running():
|
||||
docker_installed = command_exists("docker")
|
||||
if docker_installed:
|
||||
error_msg = "Docker is installed but not running"
|
||||
console.print("[red]Docker is installed but the daemon is not running.[/red]")
|
||||
console.print(
|
||||
"[yellow]Please start Docker Desktop (or the Docker daemon) and re-run this command.[/yellow]"
|
||||
)
|
||||
else:
|
||||
error_msg = "Docker is not installed"
|
||||
console.print("[red]Docker is not installed.[/red]")
|
||||
console.print(
|
||||
"[yellow]Skyvern needs Docker to run PostgreSQL. Please either:[/yellow]\n"
|
||||
" 1. Install Docker: [link]https://docs.docker.com/get-docker/[/link]\n"
|
||||
" 2. Or provide your own Postgres via: [bold]skyvern init --database-string 'postgresql+psycopg://user:pass@host:5432/dbname'[/bold]"
|
||||
)
|
||||
capture_setup_event(
|
||||
"database-fail",
|
||||
success=False,
|
||||
error_type="docker_not_running",
|
||||
error_message="Docker is not running or not installed",
|
||||
)
|
||||
console.print(
|
||||
"[red]Docker is not running or not installed. Please install or start Docker and try again.[/red]"
|
||||
error_message=error_msg,
|
||||
)
|
||||
raise SystemExit(1)
|
||||
|
||||
|
|
@ -234,4 +248,5 @@ def setup_postgresql(no_postgres: bool = False) -> None:
|
|||
else:
|
||||
console.print("✅ [green]Database and user created successfully.[/green]")
|
||||
|
||||
update_or_add_env_var("DATABASE_STRING", DEFAULT_POSTGRES_DATABASE_STRING)
|
||||
capture_setup_event("database-complete", success=True, extra_data={"source": "docker"})
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ from skyvern.utils.env_paths import resolve_backend_env_path
|
|||
|
||||
from .console import console
|
||||
|
||||
DEFAULT_POSTGRES_DATABASE_STRING = "postgresql+psycopg://skyvern@localhost:5432/skyvern"
|
||||
|
||||
|
||||
def update_or_add_env_var(key: str, value: str) -> None:
|
||||
"""Update or add environment variable in .env file."""
|
||||
|
|
@ -42,7 +44,7 @@ def update_or_add_env_var(key: str, value: str) -> None:
|
|||
"MAX_STEPS_PER_RUN": "50",
|
||||
"LOG_LEVEL": "INFO",
|
||||
"LITELLM_LOG": "CRITICAL",
|
||||
"DATABASE_STRING": "postgresql+psycopg://skyvern@localhost/skyvern",
|
||||
"DATABASE_STRING": DEFAULT_POSTGRES_DATABASE_STRING,
|
||||
"PORT": "8000",
|
||||
"ANALYTICS_ID": "anonymous",
|
||||
"ENABLE_LOG_ARTIFACTS": "false",
|
||||
|
|
|
|||
|
|
@ -34,6 +34,13 @@ def setup_windows_event_loop_policy() -> None:
|
|||
def migrate_db() -> None:
|
||||
# Import here to avoid circular import (config -> utils -> analytics -> config)
|
||||
from skyvern.analytics import capture_setup_error, capture_setup_event
|
||||
from skyvern.config import Settings, _ensure_sqlite_dir
|
||||
from skyvern.forge.sdk.settings_manager import SettingsManager
|
||||
|
||||
# Reload settings so env vars set by setup_postgresql() are picked up.
|
||||
refreshed = Settings()
|
||||
SettingsManager.set_settings(refreshed)
|
||||
_ensure_sqlite_dir(refreshed.DATABASE_STRING)
|
||||
|
||||
capture_setup_event("migration-start")
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue