fix : update cors and admin user cache

This commit is contained in:
2026-02-24 18:02:18 +08:00
parent 03b57ad514
commit 09d396c77c
16 changed files with 278 additions and 22 deletions

46
restart_prod.sh Normal file
View File

@@ -0,0 +1,46 @@
#!/bin/bash
HomeDir=/home/production/cdiscount/server
# 替 .env
rm -rf "$HomeDir/.env"
cp "$HomeDir/.env.prod" "$HomeDir/.env"
env_file="$HomeDir/.env"
# 设置 CRONTAB_ENABLE
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
# 从 server.php 中提取所有 'port' => 数字 的值(使用 grep + awk
# 匹配类似:'port' => 9501,
ports=$(grep -o "'port'[[:space:]]*=>[[:space:]]*[0-9]\+" "$HomeDir/config/autoload/server.php" | awk -F '=>' '{print $2}' | tr -d ' ,')
# 转为数组
read -a port_array <<< "$ports"
if [ ${#port_array[@]} -eq 0 ]; then
echo "Error: No valid ports found in server.php. Exiting."
exit 1
fi
echo "Detected ports: ${port_array[*]}"
# 只 kill 正在被监听的端口
for port in "${port_array[@]}"; do
if ! [[ "$port" =~ ^[0-9]+$ ]] || [ "$port" -lt 1 ] || [ "$port" -gt 65535 ]; then
echo "Warning: Skipping invalid port '$port'"
continue
fi
if ss -tuln | grep -q ":$port\b"; then
echo "Port $port is in use. Killing related processes..."
sudo lsof -i:"$port" -t | sudo xargs -r kill -9
else
echo "Port $port is not in use. Skip killing."
fi
done
echo 'Cleanup done.'
# 启动服务
source /etc/profile
mkdir -p /home/log
nohup php "$HomeDir/bin/hyperf.php" start > /home/log/hyperf_run.log 2>&1 &
echo 'Service restarted successfully on ports: '"${port_array[*]}"' '