# ==============================================
# LLMHosts -- systemd service unit
# ==============================================
# Install:
#   sudo cp contrib/llmhost.service /etc/systemd/system/
#   sudo systemctl daemon-reload
#   sudo systemctl enable llmhost
#   sudo systemctl start llmhost
#
# If llmhost is installed in a virtualenv or via pipx, update ExecStart:
#   sudo systemctl edit llmhost
#   [Service]
#   ExecStart=
#   ExecStart=/home/llmhost/.local/bin/llmhost serve --host 0.0.0.0 --no-tui

[Unit]
Description=LLMHosts AI Proxy
Documentation=https://llmhosts.com/docs
After=network-online.target ollama.service
Wants=network-online.target

[Service]
Type=simple
User=llmhost
Group=llmhost
WorkingDirectory=/home/llmhost

ExecStart=/usr/local/bin/llmhost serve --host 0.0.0.0 --no-tui
Restart=on-failure
RestartSec=5
TimeoutStartSec=30
TimeoutStopSec=15

# Environment
Environment=LLMHOST_SECURITY_REQUIREAUTH=true
Environment=LLMHOST_DASHBOARD_TUI=false
EnvironmentFile=-/home/llmhost/.llmhost/environment

# Security hardening
NoNewPrivileges=yes
ProtectSystem=strict
ProtectHome=read-only
ReadWritePaths=/home/llmhost/.llmhost
PrivateTmp=yes
ProtectKernelTunables=yes
ProtectControlGroups=yes
RestrictSUIDSGID=yes
RestrictNamespaces=yes

# Resource limits
LimitNOFILE=65536
MemoryMax=4G

[Install]
WantedBy=multi-user.target
