nginx守护进程开/关选项有什么区别? [英] What is the difference between nginx daemon on/off option?

查看:3265
本文介绍了nginx守护进程开/关选项有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我第一个Web服务器管理体验,我想要构建使用nginx作为Web服务器的docker容器。在所有docker教程中,守护程序关闭; 选项被放入主 .conf 文件中,但是省略其说明。 p>

我在互联网上搜索它,我不明白守护进程有什么区别?守护程序关闭; 选项。有些人提到守护程序关闭; 是为了生产,为什么?



你能解释一下,这两个选项,为什么我应该使用守护程序关闭; 生产?

解决方案

对于正常生产(在服务器上),请使用默认的守护程序; 指令,以便Nginx服务器将在后台启动。以这种方式,Nginx和其他服务正在运行并相互通话。一个服务器运行许多服务。



对于 Docker容器(或调试),守护程序关闭; 指令告诉Nginx留在前台。对于容器,这是有用的,因为最佳实践是一个容器=一个过程。一个服务器(容器)只有一个服务。



设置守护程序关闭; 如果有第三方主管控制您的服务的工具。主管让您一次停止/开始/获取一束服务的状态。



我使用守护程序关闭; 调整我的Nginx配置,然后干净地杀死服务并重新启动它。这样我可以快速测试配置。完成后,我使用默认的守护程序;


This is my first web-server administration experience and I want to build docker container which uses nginx as a web-server. In all docker tutorial daemon off; option is put into main .conf file but explanation about it is omitted.

I search on the internet about it and I don't understand what is the difference between daemon on; and daemon off; options. Some people mentioned that daemon off; is for production, why?

Can you explain, what is the difference between this two options, and why I should use daemon off; on production?

解决方案

For normal production (on a server), use the default daemon on; directive so the Nginx server will start in the background. In this way Nginx and other services are running and talking to each other. One server runs many services.

For Docker containers (or for debugging), the daemon off; directive tells Nginx to stay in the foreground. For containers this is useful as best practice is for one container = one process. One server (container) has only one service.

Setting daemon off; is also useful if there's a 3rd party tool like Supervisor controlling your services. Supervisor lets you stop/start/get status for bunches of services at once.

I use daemon off; for tweaking my Nginx config, then cleanly killing the service and restarting it. This lets me test configurations rapidly. When done I use the default daemon on;.

这篇关于nginx守护进程开/关选项有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆