初始化1
This commit is contained in:
32
scripts/set_timeout_12h.sh
Normal file
32
scripts/set_timeout_12h.sh
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
# 修改所有代理超时为 12 小时
|
||||
|
||||
# 1. nginx.conf http 块加全局默认
|
||||
if ! grep -q 'proxy_connect_timeout 43200s' /etc/nginx/nginx.conf; then
|
||||
sed -i '/gzip_types text\/plain/i\ proxy_connect_timeout 43200s;\n proxy_send_timeout 43200s;\n proxy_read_timeout 43200s;\n' /etc/nginx/nginx.conf
|
||||
echo "[OK] nginx.conf: global timeout 43200s"
|
||||
else
|
||||
echo "[SKIP] nginx.conf already has 43200s"
|
||||
fi
|
||||
|
||||
# 2. 修改所有 conf.d 中的超时
|
||||
for f in /etc/nginx/conf.d/*.conf; do
|
||||
sed -i 's/proxy_connect_timeout 60s;/proxy_connect_timeout 43200s;/g' "$f"
|
||||
sed -i 's/proxy_send_timeout 60s;/proxy_send_timeout 43200s;/g' "$f"
|
||||
sed -i 's/proxy_read_timeout 60s;/proxy_read_timeout 43200s;/g' "$f"
|
||||
echo "[OK] $(basename $f)"
|
||||
done
|
||||
|
||||
# 3. 更新 Python 模板
|
||||
TEMPLATE="/opt/nginx-api/services/nginx_service.py"
|
||||
if [ -f "$TEMPLATE" ]; then
|
||||
sed -i 's/proxy_connect_timeout 60s;/proxy_connect_timeout 43200s;/g' "$TEMPLATE"
|
||||
sed -i 's/proxy_send_timeout 60s;/proxy_send_timeout 43200s;/g' "$TEMPLATE"
|
||||
sed -i 's/proxy_read_timeout 60s;/proxy_read_timeout 43200s;/g' "$TEMPLATE"
|
||||
systemctl restart nginx-api
|
||||
echo "[OK] Python template updated + API restarted"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "=== nginx -t ==="
|
||||
nginx -t && systemctl reload nginx && echo "=== DONE ==="
|
||||
Reference in New Issue
Block a user