From c52d546fb1bf9eb8d4d2cb669ae25e14f015550d Mon Sep 17 00:00:00 2001 From: Haelnorr Date: Sat, 22 Feb 2025 17:12:36 +1100 Subject: [PATCH] Deleted old deploy scripts --- deploy/deploy_production.sh | 94 ------------------------------------- deploy/deploy_staging.sh | 94 ------------------------------------- 2 files changed, 188 deletions(-) delete mode 100644 deploy/deploy_production.sh delete mode 100644 deploy/deploy_staging.sh diff --git a/deploy/deploy_production.sh b/deploy/deploy_production.sh deleted file mode 100644 index bc47915..0000000 --- a/deploy/deploy_production.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/bash - -# Exit on error -set -e - -# Check if commit hash is passed as an argument -if [ -z "$1" ]; then - echo "Usage: $0 " - exit 1 -fi - -COMMIT_HASH=$1 -RELEASES_DIR="/home/deploy/releases/production" -DEPLOY_BIN="/home/deploy/production/projectreshoot" -SERVICE_NAME="projectreshoot" -BINARY_NAME="projectreshoot-production-${COMMIT_HASH}" -declare -a PORTS=("3000" "3001" "3002") - -# Check if the binary exists -if [ ! -f "${RELEASES_DIR}/${BINARY_NAME}" ]; then - echo "Binary ${BINARY_NAME} not found in ${RELEASES_DIR}" - exit 1 -fi - -# Keep a reference to the previous binary from the symlink -if [ -L "${DEPLOY_BIN}" ]; then - PREVIOUS=$(readlink -f $DEPLOY_BIN) - echo "Current binary is ${PREVIOUS}, saved for rollback." -else - echo "No symbolic link found, no previous binary to backup." - PREVIOUS="" -fi - -rollback_deployment() { - if [ -n "$PREVIOUS" ]; then - echo "Rolling back to previous binary: ${PREVIOUS}" - ln -sfn "${PREVIOUS}" "${DEPLOY_BIN}" - else - echo "No previous binary to roll back to." - fi - - # wait to restart the services - sleep 10 - - # Restart all services with the previous binary - for port in "${PORTS[@]}"; do - SERVICE="${SERVICE_NAME}@${port}.service" - echo "Restarting $SERVICE..." - sudo systemctl restart $SERVICE - done - - echo "Rollback completed." -} - -# Copy the binary to the deployment directory -echo "Promoting ${BINARY_NAME} to ${DEPLOY_BIN}..." -ln -sf "${RELEASES_DIR}/${BINARY_NAME}" "${DEPLOY_BIN}" - -WAIT_TIME=5 -restart_service() { - local port=$1 - local SERVICE="${SERVICE_NAME}@${port}.service" - echo "Restarting ${SERVICE}..." - - # Restart the service - if ! sudo systemctl restart "$SERVICE"; then - echo "Error: Failed to restart ${SERVICE}. Rolling back deployment." - - # Call the rollback function - rollback_deployment - exit 1 - fi - - # Wait a few seconds to allow the service to fully start - echo "Waiting for ${SERVICE} to fully start..." - sleep $WAIT_TIME - - # Check the status of the service - if ! systemctl is-active --quiet "${SERVICE}"; then - echo "Error: ${SERVICE} failed to start correctly. Rolling back deployment." - - # Call the rollback function - rollback_deployment - exit 1 - fi - - echo "${SERVICE}.service restarted successfully." -} - -for port in "${PORTS[@]}"; do - restart_service $port -done - -echo "Deployment completed successfully." diff --git a/deploy/deploy_staging.sh b/deploy/deploy_staging.sh deleted file mode 100644 index 3ada4c5..0000000 --- a/deploy/deploy_staging.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/bash - -# Exit on error -set -e - -# Check if commit hash is passed as an argument -if [ -z "$1" ]; then - echo "Usage: $0 " - exit 1 -fi - -COMMIT_HASH=$1 -RELEASES_DIR="/home/deploy/releases/staging" -DEPLOY_BIN="/home/deploy/staging/projectreshoot" -SERVICE_NAME="staging.projectreshoot" -BINARY_NAME="projectreshoot-staging-${COMMIT_HASH}" -declare -a PORTS=("3005" "3006" "3007") - -# Check if the binary exists -if [ ! -f "${RELEASES_DIR}/${BINARY_NAME}" ]; then - echo "Binary ${BINARY_NAME} not found in ${RELEASES_DIR}" - exit 1 -fi - -# Keep a reference to the previous binary from the symlink -if [ -L "${DEPLOY_BIN}" ]; then - PREVIOUS=$(readlink -f $DEPLOY_BIN) - echo "Current binary is ${PREVIOUS}, saved for rollback." -else - echo "No symbolic link found, no previous binary to backup." - PREVIOUS="" -fi - -rollback_deployment() { - if [ -n "$PREVIOUS" ]; then - echo "Rolling back to previous binary: ${PREVIOUS}" - ln -sfn "${PREVIOUS}" "${DEPLOY_BIN}" - else - echo "No previous binary to roll back to." - fi - - # wait to restart the services - sleep 10 - - # Restart all services with the previous binary - for port in "${PORTS[@]}"; do - SERVICE="${SERVICE_NAME}@${port}.service" - echo "Restarting $SERVICE..." - sudo systemctl restart $SERVICE - done - - echo "Rollback completed." -} - -# Copy the binary to the deployment directory -echo "Promoting ${BINARY_NAME} to ${DEPLOY_BIN}..." -ln -sf "${RELEASES_DIR}/${BINARY_NAME}" "${DEPLOY_BIN}" - -WAIT_TIME=5 -restart_service() { - local port=$1 - local SERVICE="${SERVICE_NAME}@${port}.service" - echo "Restarting ${SERVICE}..." - - # Restart the service - if ! sudo systemctl restart "$SERVICE"; then - echo "Error: Failed to restart ${SERVICE}. Rolling back deployment." - - # Call the rollback function - rollback_deployment - exit 1 - fi - - # Wait a few seconds to allow the service to fully start - echo "Waiting for ${SERVICE} to fully start..." - sleep $WAIT_TIME - - # Check the status of the service - if ! systemctl is-active --quiet "${SERVICE}"; then - echo "Error: ${SERVICE} failed to start correctly. Rolling back deployment." - - # Call the rollback function - rollback_deployment - exit 1 - fi - - echo "${SERVICE}.service restarted successfully." -} - -for port in "${PORTS[@]}"; do - restart_service $port -done - -echo "Deployment completed successfully."