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

[service]
name = "syntaxis-api"
description = "syntaxis REST API server - Project management platform API"

# Binary to execute (this is the wrapper script that injects --config)
binary = "syntaxis-api"

# Arguments - config directory is injected by wrapper script
args = [
    "--listen", "127.0.0.1:3000"
]

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

# Environment variables
[service.env]
# Logging
RUST_LOG = "syntaxis_api=info,axum=info"
RUST_BACKTRACE = "1"

# API configuration
SYNTAXIS_API_PORT = "3000"
SYNTAXIS_API_HOST = "127.0.0.1"

# Feature flags
SYNTAXIS_FEATURES_DATABASE = "true"
SYNTAXIS_FEATURES_HEALTH = "true"
SYNTAXIS_FEATURES_METRICS = "true"

# Logging configuration
[logging]
log_file = "~/.local/share/syntaxis/api.log"
level = "info"
max_backups = 10

# Health check configuration
[health_check]
# HTTP health endpoint
type = "http"
endpoint = "http://127.0.0.1:3000/health"
interval_secs = 15
timeout_secs = 5
failure_threshold = 3
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 = 4096

# Restart policy
[restart]
policy = "on-failure"
max_retries = 5
delay_secs = 3
backoff_multiplier = 1.5

# Dependencies - API depends on database
[dependencies]
wait_for = ["surrealdb"]
timeout_secs = 30

# Configuration
[configuration]
# Config directory (following syntaxis pattern)
config_dir = "~/.config/syntaxis"
config_files = [
    "syntaxis-api.toml",
    "database.toml",
    "features/auth.toml",
    "features/database.toml",
    "features/metrics.toml"
]

# Notes
[notes]
installation_required = "syntaxis binary"
binary_installation = "cargo install --path core/crates/syntaxis-api"
documentation = "docs/API_GUIDE.md"
dashboard_url = "http://127.0.0.1:3000"
required = true  # API is core to syntaxis

# Platform-specific configurations
[platform.linux]
binary = "syntaxis-api"
# Use wrapper script on Linux
wrapper_enabled = true

[platform.macos]
binary = "syntaxis-api"
# Use wrapper script on macOS
wrapper_enabled = true

[platform.windows]
binary = "syntaxis-api.exe"
wrapper_enabled = false
