diff --git a/check_and_restart.sh b/check_and_restart.sh new file mode 100755 index 0000000..d440edd --- /dev/null +++ b/check_and_restart.sh @@ -0,0 +1,19 @@ +#!/bin/sh +#!/bin/bash + +# pull changes from the repo +git pull + +# Set the time threshold in seconds (6 hours = 21600 seconds) +time_threshold=21600 + +# Get the timestamp of the most recent commit +last_commit_time=$(git log -1 --format="%at") + +# Check if the last commit was within the time threshold +if [[ $(( $(date +%s) - last_commit_time )) -lt $time_threshold ]]; then + echo "Restarting..." + pm2 restart ecosystem.config.js +else + echo "There has been no commit. Will not restart." +fi diff --git a/ecosystem.config.js b/ecosystem.config.js new file mode 100644 index 0000000..51d90cb --- /dev/null +++ b/ecosystem.config.js @@ -0,0 +1,6 @@ +module.exports = { + apps : [{ + name : "Xantic", + script : "./index.js", + }] +}