2025-02-24 20:05:20 +08:00

25 lines
688 B
Bash

#!/bin/bash
log_file="/root/advisor_server.log"
# 检查服务是否正在运行
status=$(systemctl is-active advisor-server.service)
if [ "$status" == "active" ]; then
# 如果服务已经在运行,重启服务
echo "AdvisorServer is running. Restarting the service..."
systemctl restart advisor-server.service
if [ $? -eq 0 ]; then
echo "AdvisorServer restarted successfully."
else
echo "Failed to restart AdvisorServer."
fi
else
echo "AdvisorServer is not running. Starting the service..."
systemctl start advisor-server.service
if [ $? -eq 0 ]; then
echo "AdvisorServer started successfully."
else
echo "Failed to start AdvisorServer."
fi
fi