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

feat: check if the app is running before run #147

Merged
merged 1 commit into from
Nov 27, 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
7 changes: 6 additions & 1 deletion spaceship/templates/script/files/faucet.sh.plush
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,19 @@ ensure_directory_exists() {
}

start() {
if [ -f "$PID_FILE" ] && ps -p "$(cat "$PID_FILE")" > /dev/null; then
echo "faucet is already running with PID $(cat "$PID_FILE")."
return
fi

ensure_directory_exists "$PID_FILE"
LOG_FILE=$(get_log_file_name)
ensure_directory_exists "$LOG_FILE"

echo "Starting faucet on port $PORT..."
nohup $COMMAND > "$LOG_FILE" 2>&1 &
echo $! > "$PID_FILE"
echo "faucet started with PID $(cat $PID_FILE)."
echo "faucet started with PID $(cat "$PID_FILE")."
echo "Logs are being written to $LOG_FILE"
}

Expand Down
7 changes: 6 additions & 1 deletion spaceship/templates/script/files/run.sh.plush
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@ ensure_directory_exists() {
}

start() {
if [ -f "$PID_FILE" ] && ps -p "$(cat "$PID_FILE")" > /dev/null; then
echo "$BINARY is already running with PID $(cat "$PID_FILE")."
return
fi

ensure_directory_exists "$PID_FILE"
LOG_FILE=$(get_log_file_name)
ensure_directory_exists "$LOG_FILE"

echo "Starting $COMMAND..."
nohup $COMMAND > "$LOG_FILE" 2>&1 &
echo $! > "$PID_FILE"
echo "$BINARY started with PID $(cat $PID_FILE)."
echo "$BINARY started with PID $(cat "$PID_FILE")."
echo "Logs are being written to $LOG_FILE"
}

Expand Down
Loading