File name
Commit message
Commit date
#!/bin/bash
# Array to hold the process IDs
declare -a pids
PYTHONPATH="/home/juni/PycharmProjects/segmentation_overlapping"
# Start multiple Python processes in the background
python streaming_process.py --cctv_num 0 &
pids+=($!)
python streaming_process.py --cctv_num 1 &
pids+=($!)
#python test.py
python inference_endpoint.py
#gunicorn --workers=6 inference_endpoint:app
pids+=($!)
# Function to kill all processes
cleanup() {
echo "Terminating all processes..."
for pid in "${pids[@]}"; do
# Attempt to terminate the process
kill -9 $pid
# Wait a bit for the process to terminate
sleep 1
# Check if the process is still running
if kill -0 $pid 2>/dev/null; then
echo "Process $pid did not terminate, trying again..."
kill -9 $pid
sleep 1 # Wait a bit before checking again
# Final check - if it still didn't terminate, report failure
if kill -0 $pid 2>/dev/null; then
echo "Failed to terminate process $pid."
else
echo "Process $pid terminated successfully after retry."
fi
else
echo "Process $pid terminated successfully."
fi
done
echo "Exiting script."
exit 0 # Exit the script
}
# Trap keyboard interrupt and call cleanup
trap cleanup SIGINT
# Print message
echo "Running... Press Ctrl+C to stop."
# Wait forever until Ctrl+C is pressed
while true; do
sleep 1
done