Add script for running server, restarting when new version pushed
This commit is contained in:
parent
6ca589e3e6
commit
6d7bf48570
2 changed files with 23 additions and 2 deletions
|
@ -1,4 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
|
||||||
BUILD_NAME=`ls -t target/builds | head -1`
|
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
|
||||||
|
|
19
scripts/server_watch.sh
Executable file
19
scripts/server_watch.sh
Executable file
|
@ -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
|
Loading…
Reference in a new issue