upstart-20190417-Ubuntu 14.04 利用 upstart 守護 Nginx 進程

Intro

用 Ubuntu 的 upstart 守護 Nginx

Solution

# /etc/init/nginx.conf

description "nginx - small, powerful, scalable web/proxy server"

start on filesystem and static-network-up
stop on runlevel [016]

expect fork
respawn

pre-start script
        [ -x /usr/sbin/nginx ] || { stop; exit 0; }
        /usr/sbin/nginx -q -t -g 'daemon on; master_process on;' || { stop; exit 0; }
end script

exec /usr/sbin/nginx -g 'daemon on; master_process on;'

pre-stop exec /usr/sbin/nginx -s quit

刷新配置使其生效即可

# 刷新配置
initctl reload-configuration

# 加入 nginx
initctl start nginx
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章