From 4eaad008e1c0c499f1a9657fe0c8e98c6a812475 Mon Sep 17 00:00:00 2001 From: tyrin Date: Thu, 12 Sep 2024 11:50:23 +0300 Subject: [PATCH] added the monitor script cycle.sh. Made it check for the finish flag file. Added the finish flag generation to ingester. --- cycle.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 cycle.sh diff --git a/cycle.sh b/cycle.sh new file mode 100644 index 0000000..67a7373 --- /dev/null +++ b/cycle.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# Function to run the command +run_command() { + python manage.py ingester & + PID=$! + echo "Started process with PID: $PID" +} + +# Function to terminate the command +interrupt_command() { + kill -SIGINT $PID + echo "Interrupted process with PID: $PID" +} + +# Run the command initially +run_command + +# Loop to restart the command every 2 hours until ingester_done.flag is found +while [ ! -f ingester_done.flag ]; do + # Wait for 2 hours (7200 seconds) + sleep 7200 + + # Terminate the command + interrupt_command + + # Restart the command + run_command +done + +echo "ingester_done.flag found. Exiting script."