# Gadget Code Platform — Systemd Service Unit
# ============================================================================
# Install to: /etc/systemd/system/gadget-code-web.service
#
# Then:
#   sudo systemctl daemon-reload
#   sudo systemctl enable gadget-code-web
#   sudo systemctl start gadget-code-web
#
# View logs:
#   journalctl -u gadget-code-web -f
# ============================================================================

[Unit]
Description=Gadget Code — Agentic Engineering Platform
Documentation=https://github.com/dtp-technologies/gadget-code
After=network.target mongod.service redis.service
Wants=mongod.service redis.service

[Service]
Type=simple
User=gadget
Group=gadget

# Environment variables for secrets (see docs/install/env-examples/)
EnvironmentFile=/etc/gadget/gadget-code-web.env

# Binary path (adjust if installed globally via npm)
ExecStart=/usr/local/bin/gadget-code-web
Restart=on-failure
RestartSec=5

# Security hardening
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=read-only
ReadWritePaths=/tmp/gadget-code
PrivateTmp=true

# Resource limits
LimitNOFILE=65536

# Logging
StandardOutput=journal
StandardError=journal
SyslogIdentifier=gadget-code-web

[Install]
WantedBy=multi-user.target
