chore: add deploy.sh for prod restarts
This commit is contained in:
@@ -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
|
||||||
Reference in New Issue
Block a user