Files
hyperf_service/restart_prod.sh
2025-07-15 16:07:55 +08:00

26 lines
636 B
Bash
Executable File
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
HomeDir=/home/production/api_service
rm -rf $HomeDir/.env
cp $HomeDir/env.prod $HomeDir/.env
env_file=$HomeDir/.env
#先判断是否存在某个文件构建配置文件
if [ -e $HomeDir/../cron_true.txt ]; then
sed -i 's/^CRONTAB_ENABLE=.*/CRONTAB_ENABLE=true/' "$env_file"
else
sed -i 's/^CRONTAB_ENABLE=.*/CRONTAB_ENABLE=false/' "$env_file"
fi
#杀死进程并重启进程
sudo lsof -i:9501|grep -v PID|awk '{print $2}'|sudo xargs kill -9
echo 'kill success';
source /etc/profile
/bin/nohup php $HomeDir/bin/hyperf.php start > /home/log/hyperf_run.log 2>&1 &
echo 'The service restart success';