From 02a65f788ce236aadcec24c0da31ec80aabcf563 Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Wed, 23 Dec 2020 17:41:34 -0500 Subject: [PATCH] make: Update release target to use rc.d init script The whole restart.sh model was... well, clever but also pretty wacky! I've been running under the rc.d script for a while now, which has many advantages (but most importantly means I can reboot the server and have the service come back online...). So this patch removes the whole concept of preprod vs prod (we aren't editing the code much these days!) as well as restart.sh. Ah. Much simpler. --- Makefile | 11 +++-------- bin/restart.sh | 52 ---------------------------------------------------- 2 files changed, 3 insertions(+), 60 deletions(-) delete mode 100755 bin/restart.sh diff --git a/Makefile b/Makefile index c3781fe..59f3745 100644 --- a/Makefile +++ b/Makefile @@ -35,14 +35,9 @@ release: build test git show HEAD --pretty=full -s |\ sed 's/\(Author\|Commit\): \([^<]\+\).*/\1: \2/' > build/public/version.txt rsync -av --delete --rsh="ssh -o StrictHostKeyChecking=no" \ - build/ _euchre@euchre.live:preprod-el/ - ssh -o StrictHostKeyChecking=no _euchre@euchre.live \ - env FORCE=$(FORCE) sh restart.sh preprod - -.PHONY: release-prod -release-prod: release - ssh -o StrictHostKeyChecking=no _euchre@euchre.live \ - env FORCE=$(FORCE) UPDATE=1 sh restart.sh prod + build/ _euchre@euchre.live:prod-el/ + ssh -t -o StrictHostKeyChecking=no euchre.live \ + doas rcctl restart euchre .PHONY: clean clean: diff --git a/bin/restart.sh b/bin/restart.sh deleted file mode 100755 index 30d8d60..0000000 --- a/bin/restart.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh -# no more tmux for daemons -# A safe restart script to be run on the server -set -e -die() { - echo "$1" 1>&2 - exit 1 -} - -HOST=localhost - -restart() { - name="$1" - port="$2" - if pgrep -f "gloat.pl.*$port"; then - if [ -z "$FORCE" ]; then - curl -s $HOST:$port/stats | grep -q "0 Players" || die "Players on server" - fi - - printf "%s" "Killing old server... " - pkill -f "gloat.pl.*$port" - sleep 2 # not needed? - echo "Check!" - fi - - if [ -n "$UPDATE" ]; then - printf "%s" "Updating preprod -> prod..." - rm -rf $HOME/prod-el - cp -a $HOME/preprod-el $HOME/prod-el - echo "Check!" - fi - - if [ $name = "preprod" ]; then - export MOJO_MODE=development - else - export MOJO_MODE=production - fi - - printf "%s" "Starting new server... " - $HOME/${name}-el/gloat.pl daemon -l http://*:$port >> /var/log/gloat/$name.log 2>&1 & - sleep 2 - echo "Check!" - - curl -s $HOST:$port/stats | grep "Server Start" -} - -# Decide which server to restart based on the first arg -case "$1" in - preprod) restart "preprod" 3001 ;; - prod) restart "prod" 3000 ;; - *) die "usage: restart.sh prod|preprod" ;; -esac -- libgit2 1.1.1