added pm2 and cron scripts

Signed-off-by: Rajdeep Malakar <rajdeepm.dev@gmail.com>
This commit is contained in:
Rajdeep Malakar 2024-03-06 14:03:48 +05:30
parent bb4a1d5cf5
commit 595c6836d9
No known key found for this signature in database
GPG Key ID: BB9202F5967BAC9C
2 changed files with 25 additions and 0 deletions

19
check_and_restart.sh Executable file
View File

@ -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

6
ecosystem.config.js Normal file
View File

@ -0,0 +1,6 @@
module.exports = {
apps : [{
name : "Xantic",
script : "./index.js",
}]
}