From 055fb04c1327bf2cfa15af26519a65b5c52e09cd Mon Sep 17 00:00:00 2001 From: rota3015 Date: Sun, 5 May 2024 01:22:15 +0000 Subject: [PATCH] Added run.sh This file is responsible for checking after 30 minutes if the backend is running or not, if not it is responsible for starting the backend --- run.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 run.sh diff --git a/run.sh b/run.sh new file mode 100644 index 0000000..466e1c6 --- /dev/null +++ b/run.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +while true; do + # Check if the Node.js app is running on port 3000 + if ! lsof -i :3000 > /dev/null; then + + echo "Node.js app is not running on port 3000. Starting it" + cd /app/data/public/communityRuleBackend + node app.js & + else + echo "$(lsof -i :3000)" + echo "(lsof -i :3000)" + echo "Node.js app is already running on port 3000. Nothing to do" + fi + + # Sleep for 30 minutes (1800 seconds) + + sleep 1800 +done