Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent start from running if pid file exists #27

Merged
merged 1 commit into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion etc/start_helper_sidecar.sh
Original file line number Diff line number Diff line change
@@ -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
Comment on lines +3 to +8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure the PID file directory exists before checking for the file.

If the .draft/pids directory does not exist, the script will fail when attempting to create the PID file. Consider adding a check to create the directory if it does not exist.

pid_file=".draft/pids/helper_sidecar.pid"

# Ensure the PID file directory exists
mkdir -p "$(dirname "$pid_file")"

# 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
Expand All @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure the PID file is removed upon process termination.

To prevent stale PID files from causing issues, consider adding a trap to remove the PID file when the process terminates.

trap "rm -f '$pid_file'" EXIT

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

9 changes: 8 additions & 1 deletion etc/start_local_dev.sh
Original file line number Diff line number Diff line change
@@ -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
Comment on lines +3 to +8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure the PID file directory exists before checking for the file.

If the .draft/pids directory does not exist, the script will fail when attempting to create the PID file. Consider adding a check to create the directory if it does not exist.

pid_file=".draft/pids/local_dev.pid"

# Ensure the PID file directory exists
mkdir -p "$(dirname "$pid_file")"

# 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure the PID file is removed upon process termination.

To prevent stale PID files from causing issues, consider adding a trap to remove the PID file when the process terminates.

trap "rm -f '$pid_file'" EXIT

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

Loading