#!/usr/bin/env bash
set -euo pipefail

sudo tee /etc/systemd/system/athena.service > /dev/null <<'EOF'
[Unit]
Description=Athena API
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=xbp
Group=xbp
WorkingDirectory=/home/xbp/github/xylex-group/athena
Environment="PORT=4052"
Environment="NODE_ENV=production"
ExecStart=/home/xbp/github/xylex-group/athena/athena_rs --api-only --port 4052
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable --now athena.service
