chore: add deploy.sh for prod restarts
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled

This commit is contained in:
2026-05-07 12:02:28 -04:00
parent a3a6f765e7
commit 19517b0847
+23
View File
@@ -0,0 +1,23 @@
#!/bin/bash
# Define the service name/path for easy updates
BINARY_NAME="gophergate"
SOURCE_PATH="./cmd/gophergate/main.go"
echo "Stopping existing $BINARY_NAME processes..."
# Using pkill; || true ensures the script continues even if no process was found
pkill -9 "$BINARY_NAME" || echo "No running process found."
echo "Pulling latest changes from git..."
git pull
echo "Building the application..."
if go build -o "$BINARY_NAME" "$SOURCE_PATH"; then
echo "Build successful. Starting $BINARY_NAME in the background..."
# Launch with nohup and redirect output to a log file
nohup "./$BINARY_NAME" > gophergate.log 2>&1 &
echo "Service started. PID: $!"
else
echo "Build failed! Keeping the previous state."
exit 1
fi