# SurrealDB Service Definition for provctl
#
# This file defines how SurrealDB is managed by provctl.
# Usage: provctl deploy --config configs/provisioning/services/surrealdb.toml

[service]
name = "surrealdb"
description = "SurrealDB - Multi-backend database server"

# Binary to execute (expects 'surreal' command in PATH)
binary = "surreal"

# Arguments for the service
# Mode: server (local), docker, kubernetes are handled via presets
args = [
    "start",
    "--bind", "127.0.0.1:8000",
    "memory"
]

# Working directory
working_dir = "~/.local/share/surrealdb"

# Environment variables
[service.env]
SURREALDB_LOG = "info"
RUST_LOG = "surrealdb=info"

# Logging configuration
[logging]
# Log file location
log_file = "~/.local/share/surrealdb/surrealdb.log"
# Log level: debug, info, warn, error
level = "info"
# Keep how many old logs
max_backups = 5

# Health check configuration
[health_check]
# Type: command, http, tcp, custom
type = "tcp"
# Address to check
address = "127.0.0.1"
port = 8000
# How often to check (seconds)
interval_secs = 5
# Timeout for each check
timeout_secs = 3
# Failure threshold (consecutive failures to mark unhealthy)
failure_threshold = 3
# Success threshold (consecutive successes to mark healthy)
success_threshold = 2

# Resource limits
[resources]
# Memory limit (MB)
memory_limit_mb = 512
# CPU limit (0 = unlimited)
cpu_limit = 0
# File descriptor limit
file_descriptor_limit = 1024

# Restart policy
[restart]
# always, on-failure, no
policy = "on-failure"
# Max restart attempts (for on-failure)
max_retries = 5
# Delay between restarts (seconds)
delay_secs = 2
# Backoff multiplier
backoff_multiplier = 1.5

# Dependencies
[dependencies]
# Wait for these services before starting
wait_for = []

# Notes
[notes]
installation_required = "surreal CLI"
installation_command = "cargo install surrealdb-cli"
documentation = "https://surrealdb.com/docs/start"

# Platform-specific configurations
[platform.linux]
binary = "surreal"

[platform.macos]
binary = "surreal"

[platform.windows]
binary = "surreal.exe"
