diff --git a/spaceship/templates/script/files/faucet.sh.plush b/spaceship/templates/script/files/faucet.sh.plush index ca8bcc18..237df447 100644 --- a/spaceship/templates/script/files/faucet.sh.plush +++ b/spaceship/templates/script/files/faucet.sh.plush @@ -20,6 +20,11 @@ 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" @@ -27,7 +32,7 @@ start() { 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" } diff --git a/spaceship/templates/script/files/run.sh.plush b/spaceship/templates/script/files/run.sh.plush index 378c6cfe..7dd313ac 100644 --- a/spaceship/templates/script/files/run.sh.plush +++ b/spaceship/templates/script/files/run.sh.plush @@ -21,6 +21,11 @@ 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" @@ -28,7 +33,7 @@ start() { 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" }