Skip to content

Commit

Permalink
check if the app is running before run (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pantani authored Nov 27, 2024
1 parent 5b0ec6e commit d60f3a3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
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

0 comments on commit d60f3a3

Please sign in to comment.