kangda/stop.sh
2025-05-30 11:40:27 +08:00

28 lines
525 B
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 参数检查
if [ $# -ne 1 ]; then
echo "用法: $0 <项目目录>"
exit 1
fi
project_dir="$1"
pid_file="${project_dir}/service.pid"
# 检查PID文件是否存在
if [ ! -f "$pid_file" ]; then
echo "错误: PID文件不存在服务可能未运行"
exit 1
fi
# 停止进程
pid=$(cat "$pid_file")
if kill -0 "$pid" >/dev/null 2>&1; then
kill "$pid"
rm "$pid_file"
echo "服务已停止 (PID: $pid)"
else
echo "错误: 进程 $pid 未运行"
rm "$pid_file"
exit 1
fi