From aec7d9ac3e059a8c3301fa6320644f9cd13617a7 Mon Sep 17 00:00:00 2001 From: Erik Taubeneck Date: Wed, 15 May 2024 17:42:31 -0700 Subject: [PATCH] prevent start from running if pid file exists --- etc/start_helper_sidecar.sh | 9 ++++++++- etc/start_local_dev.sh | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/etc/start_helper_sidecar.sh b/etc/start_helper_sidecar.sh index cf1f018..29ab609 100755 --- a/etc/start_helper_sidecar.sh +++ b/etc/start_helper_sidecar.sh @@ -1,5 +1,12 @@ #!/bin/bash +pid_file=".draft/pids/helper_sidecar.pid" +# Check if pid file exists +if [ -f "$pid_file" ]; then + echo "Error: $pid_file already exists." + exit 1 +fi + config_path=$1 root_path=$2 root_domain=$3 @@ -8,4 +15,4 @@ helper_port=$5 sidecar_port=$6 identity=$7 -nohup draft run-helper-sidecar --config_path "$config_path" --root_path "$root_path" --root_domain "$root_domain" --sidecar_domain "$sidecar_domain" --helper_port "$helper_port" --sidecar_port "$sidecar_port" --identity "$identity" > .draft/logs/helper_sidecar.log 2>&1 & echo $! > .draft/pids/helper_sidecar.pid +nohup draft run-helper-sidecar --config_path "$config_path" --root_path "$root_path" --root_domain "$root_domain" --sidecar_domain "$sidecar_domain" --helper_port "$helper_port" --sidecar_port "$sidecar_port" --identity "$identity" > .draft/logs/helper_sidecar.log 2>&1 & echo $! > $pid_file diff --git a/etc/start_local_dev.sh b/etc/start_local_dev.sh index 97f61a3..98f4a4a 100755 --- a/etc/start_local_dev.sh +++ b/etc/start_local_dev.sh @@ -1,8 +1,15 @@ #!/bin/bash +pid_file=".draft/pids/local_dev.pid" +# Check if pid file exists +if [ -f "$pid_file" ]; then + echo "Error: $pid_file already exists." + exit 1 +fi + config_path=$1 root_path=$2 helper_start_port=$3 sidecar_start_port=$4 -nohup draft run-local-dev --config_path "$config_path" --root_path "$root_path" --helper_start_port "$helper_start_port" --sidecar_start_port "$sidecar_start_port" > .draft/logs/local_dev.log 2>&1 & echo $! > .draft/pids/local_dev.pid +nohup draft run-local-dev --config_path "$config_path" --root_path "$root_path" --helper_start_port "$helper_start_port" --sidecar_start_port "$sidecar_start_port" > .draft/logs/local_dev.log 2>&1 & echo $! > $pid_file