27 lines
527 B
Bash
Executable File
27 lines
527 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
PID_DIR="$ROOT_DIR/.pids"
|
|
|
|
stop_pid_file() {
|
|
local name="$1"
|
|
local file="$PID_DIR/$name.pid"
|
|
if [[ ! -f "$file" ]]; then
|
|
echo "$name pid file not found"
|
|
return
|
|
fi
|
|
local pid
|
|
pid="$(cat "$file")"
|
|
if [[ -n "$pid" ]] && kill -0 "$pid" >/dev/null 2>&1; then
|
|
kill -TERM "$pid"
|
|
echo "$name stopped: $pid"
|
|
else
|
|
echo "$name already stopped"
|
|
fi
|
|
rm -f "$file"
|
|
}
|
|
|
|
stop_pid_file api
|
|
stop_pid_file web
|