diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 0045620..4e20c13 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -1,4 +1,6 @@ -#!/bin/bash +#!/bin/sh BUILD_NAME=`ls -t target/builds | head -1` -scp target/builds/$BUILD_NAME $GRUB_USER@$GRUB_SERVER:$GRUB_RELEASE_DIR/$BUILD_NAME +SERVER_URL=$GRUB_USER@$GRUB_SERVER:$GRUB_RELEASE_DIR/$BUILD_NAME +echo "Deploying to $SERVER_URL" +scp target/builds/$BUILD_NAME $SERVER_URL diff --git a/scripts/server_watch.sh b/scripts/server_watch.sh new file mode 100755 index 0000000..7525143 --- /dev/null +++ b/scripts/server_watch.sh @@ -0,0 +1,19 @@ +#!/bin/sh +# Helper script for simple deployments. +# +# Runs the latest JAR file from the given directory. +# When a new file is added to the directory, the process +# is killed and the most recent file is run. +# If the script is killed the running processes will also +# be killed. +trap "trap - TERM && echo 'Caught SIGTERM, sending SIGTERM to process group' && kill -- -$$" INT TERM EXIT +while true; do + LATEST_BUILD=`ls -r $GRUB_RELEASE_DIR | head -1 | tr -d '\n'` + echo "Starting server package $LATEST_BUILD" + java -jar $GRUB_RELEASE_DIR/$LATEST_BUILD prod & + PID=$! + echo "Watching server directory for new files, restarting server on change" + inotifywait -e close_write -r $GRUB_RELEASE_DIR + echo "Restarting server" + kill $PID +done