## Overview Deploy `estus-shots` to the personal Fedora server manually—no CI/CD required. The application runs behind Nginx via a reverse proxy and is supervised by `systemd`. ## Prerequisites - Fedora (server) with SSH access for a user that can `sudo` without a passwordless setup. - Nim toolchain installed locally (for `nim`/`nimble`). - Server already provisioned with Nim runtime dependencies. - Existing Nginx site definition that proxies traffic to the `estus-shots` service port (defaults to `127.0.0.1:9000`). ## One-time server setup 1. Create deployment directories on the server: ```fish ssh user@server 'sudo mkdir -p /opt/estus-shots/bin /opt/estus-shots/config && sudo chown ${USER}:${USER} /opt/estus-shots -R' ``` 2. Copy the `systemd` unit and enable it: ```fish printf '%s\n' "[Unit]" \ "Description=estus-shots web service" \ "After=network.target" \ "" \ "[Service]" \ "Type=simple" \ "ExecStart=/opt/estus-shots/bin/estus-shots" \ "Restart=on-failure" \ "RestartSec=5" \ "User=www-data" \ "WorkingDirectory=/opt/estus-shots" \ "Environment=LOG_LEVEL=info" \ "" \ "[Install]" \ "WantedBy=multi-user.target" \ | ssh user@server 'sudo tee /etc/systemd/system/estus-shots.service' ssh user@server 'sudo systemctl daemon-reload && sudo systemctl enable estus-shots.service' ``` 3. Ensure Nginx reverse proxy points to `127.0.0.1:9000` and reload it once configured: ```fish ssh user@server 'sudo systemctl restart nginx' ``` ## Deployment script Save the following as `scripts/deploy.fish` (or another preferred location) and make it executable with `chmod +x scripts/deploy.fish`. ```fish #!/usr/bin/env fish set -e set SERVER user@server set TARGET_DIR /opt/estus-shots set BIN_NAME estus-shots echo 'Building project locally (release)...' nimble build -y echo 'Uploading binary...' scp bin/$BIN_NAME $SERVER:$TARGET_DIR/bin/ echo 'Uploading static assets...' scp -r src/static $SERVER:$TARGET_DIR/ echo 'Restarting services...' ssh $SERVER 'sudo systemctl restart estus-shots.service' ssh $SERVER 'sudo systemctl restart nginx' echo 'Deployment finished.' ``` > The script prompts for the SSH password and any required `sudo` password on the server. ## Manual deployment steps 1. Build the project locally: ```fish nimble build -y ``` 2. Copy the new build output and static assets: ```fish scp bin/estus-shots user@server:/opt/estus-shots/bin/ scp -r src/static user@server:/opt/estus-shots/ ``` 3. Restart the service and, if needed, Nginx: ```fish ssh user@server 'sudo systemctl restart estus-shots.service' ssh user@server 'sudo systemctl restart nginx' ``` ## Verification - Check service status: ```fish ssh user@server 'systemctl status estus-shots.service --no-pager' ``` - Review recent logs: ```fish ssh user@server 'journalctl -u estus-shots.service -n 50 --no-pager' ``` ## Troubleshooting tips - If the service fails, run it manually on the server to capture stdout/stderr: `bin/estus-shots`. - Ensure SELinux contexts allow Nginx to proxy (`setsebool -P httpd_can_network_connect 1`). - Validate reverse proxy config: `sudo nginx -t`.