Nginx


# Graceful shutdown
nginx -s quit
kill -QUIT `cat /var/run/nginx.pid`

# Quick shutdown
nginx -s stop
kill -TERM `cat /var/run/nginx.pid`
kill -INT `cat /var/run/nginx.pid`

# Graceful shutdown workers
kill -WINCH `cat /var/run/nginx.pid`

# Configuration reload
# Start the new worker processes with a new configuration
# Gracefully shutdown the old worker processes
nginx -s reload
kill -HUP `cat /var/run/nginx.pid`

# 分割日志
cd /var/log/nginx
mv access.log access.log.0
mv error.log error.log.0
# Reopen the log files
kill -USR1 `cat /var/run/nginx.pid`
# nginx -s reopen
sleep 3
gzip access.log.0 error.log.0

# 平滑升级
# Upgrade nginx
emerge nginx
# Upgrade Executable on the fly
kill -USR2 `cat /var/run/nginx.pid`
# 此时新旧主进程和工作进程同时工作, 新主进程 /var/run/nginx.pid, 旧主进程 /var/run/nginx.pid.oldbin
# 旧的工作进程继续处理已存在的连接, 不再处理新的连接, 新的连接由新进程接手
# 此时可以决定要升级还是还原
# 升级, 则结束旧的进程
kill -TERM `cat /var/run/nginx.pid.oldbin`
# 还原, 则结束新的进程
kill -TERM `cat /var/run/nginx.pid`
# nginx -s quit
# nginx -s stop