From 19517b08479fd7361a71bc568dde4804226efac1 Mon Sep 17 00:00:00 2001 From: hobokenchicken Date: Thu, 7 May 2026 12:02:28 -0400 Subject: [PATCH] chore: add deploy.sh for prod restarts --- deploy.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 deploy.sh diff --git a/deploy.sh b/deploy.sh new file mode 100644 index 00000000..c5da7ee7 --- /dev/null +++ b/deploy.sh @@ -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