[Unit]
Description=Companion AI Vault Indexer
Documentation=https://github.com/santhoshjan/companion
After=network.target companion-api.service
Wants=companion-api.service

[Service]
Type=simple
User=companion
Group=companion
WorkingDirectory=/opt/companion
Environment=PYTHONPATH=/opt/companion
Environment=COMPANION_CONFIG=/opt/companion/config.json
Environment=COMPANION_DATA_DIR=/var/lib/companion

# Start the file watcher for auto-sync
ExecStart=/opt/companion/venv/bin/python -m companion.indexer_daemon.watcher

# Or use the CLI for scheduled sync (uncomment to use):
# ExecStart=/opt/companion/venv/bin/python -m companion.indexer_daemon.cli sync

# Restart on failure
Restart=on-failure
RestartSec=10

# Resource limits
MemoryMax=1G
CPUQuota=100%

# Security hardening
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/var/lib/companion

[Install]
WantedBy=multi-user.target
