-
Notifications
You must be signed in to change notification settings - Fork 2
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
|
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
There was a problem hiding this comment.
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.