从运行nginx进程中转储conf [英] dump conf from running nginx process

查看:84
本文介绍了从运行nginx进程中转储conf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以仅从正在运行的nginx进程中获取nginx正在使用哪个conf?

Is it possible to get which conf the nginx is using only from a running nginx process?

获取conf文件路径.有时ps aux揭示它,有时却没有.可能就像nginx: master process /usr/sbin/nginx(与/proc/PID/cmdline一样)

To get the conf file path. sometimes ps aux reveal it, sometimes it doesn't. It might be just something like nginx: master process /usr/sbin/nginx (same as /proc/PID/cmdline)

  1. 那么nginx -V是唯一的解决方案吗?
  2. 此问题中,是否可以直接从nginx进程中转储conf数据结构?还是至少转储conf文件路径?
  1. So is nginx -V the only solution?
  2. From this question, is it possible to dump conf data structure from nginx process directly? Or at least dump the conf file path?

推荐答案

从Nginx 1.9.2开始,您可以使用-T标志转储Nginx配置:

As of Nginx 1.9.2 you can dump the Nginx config with the -T flag:

-T-与-t相同,但另外将配置文件转储到标准输出(1.9.2).

-T — same as -t, but additionally dump configuration files to standard output (1.9.2).

来源: http://nginx.org/en/docs/switches.html

这与特定进程的转储不同.如果您的Nginx使用其他配置文件,请检查ps aux的输出,并使用它提供的任何内容作为二进制文件,例如如果它给出类似的东西

This is not the same as dumping for a specific process. If your Nginx is using a different config file, check the output for ps aux and use whatever it gives as the binary, e.g. if it gives something like

nginx: master process /usr/sbin/nginx -c /some/other/config

您需要运行

/usr/sbin/nginx -c /some/other/config -T

如果尚未使用1.9.2,则可以使用gdb转储配置:

If you are not on 1.9.2 yet, you can dump the config with gdb:

这篇关于从运行nginx进程中转储conf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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