[Unit]
Description=Lemonade Server
Documentation=https://lemonade-server.ai/docs/
After=network-online.target

[Service]
Type=simple
User=lemonade
Group=lemonade
StateDirectory=lemonade
StateDirectoryMode=0750
# CacheDirectory for $XDG_CACHE_HOME-style lemonade cache
CacheDirectory=lemonade
CacheDirectoryMode=0755
# RuntimeDirectory for ephemeral state (PID files, Unix sockets)
RuntimeDirectory=lemonade
RuntimeDirectoryMode=0700
# HuggingFace model cache for the system service
Environment=HF_HOME=/var/cache/huggingface
WorkingDirectory=%S/lemonade
# Server settings (port, host, models_dir, …) live in config.json, not env vars.
# The few env vars lemond still reads (HF_TOKEN, LEMONADE_API_KEY,
# LEMONADE_ADMIN_API_KEY) can be set via `systemctl edit lemond` drop-ins or the
# optional environment file below.
EnvironmentFile=-/etc/default/lemond
ExecStart=@CMAKE_INSTALL_FULL_BINDIR@/lemond
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
RestartSec=5s
KillSignal=SIGINT
AmbientCapabilities=CAP_SYS_RESOURCE

# Security hardening
PrivateTmp=yes
NoNewPrivileges=yes
ProtectSystem=full
ProtectHome=yes
RestrictRealtime=yes
RestrictNamespaces=yes
LockPersonality=yes

[Install]
WantedBy=multi-user.target
