[Unit]
Description=Small server for creating HTTP endpoints (hooks)
Documentation=https://github.com/adnanh/webhook/
After=network-online.target
Wants=network-online.target
ConditionPathExists=/etc/webhook.conf


[Service]
Type=simple

# Clear any existing ExecStart from a base unit file, if any
ExecStart=
# Path to webhook, IP, port, path to hooks config, verbose logging, hot-reloading config
ExecStart=/usr/bin/webhook -ip 10.0.0.1 -port 9000 -verbose -nopanic -hooks /etc/webhook.conf

# --- Security & User (Recommended) ---
# 1. Create a dedicated user:
#    sudo useradd --system --no-create-home --shell /bin/false webhooksvc
# 2. Ensure this user can read /etc/webhook.conf and execute redeploy.sh
#    sudo chown webhooksvc:webhooksvc /etc/webhook.conf && sudo chmod 640 /etc/webhook.conf
#    Also grant sudo rights for systemctl restart as mentioned in Step 3.1.
# Uncomment and use if you created the 'webhooksvc' user:
# User=webhooksvc
# Group=webhooksvc
# If running as root (less secure), leave User/Group commented.

Restart=on-failure
RestartSec=5s
TimeoutStopSec=30s
StandardOutput=journal
StandardError=journal

[Install]
WantedBy=multi-user.target