我的 Nginx 服务器(Ubuntu 22.04 LTS)
运行正常,我没有发现任何问题。但是,我注意到状态信息中有一个不寻常的输出:
sudo systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2024-02-09 11:16:54 CET; 4 days ago
Docs: man:nginx(8)
Process: 776 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 874 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 879 (nginx)
Tasks: 5 (limit: 14170)
Memory: 15.6M
CPU: 801ms
CGroup: /system.slice/nginx.service
├─ 879 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
├─320285 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─320286 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─320287 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
└─320288 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
Feb 09 11:16:54 hostname systemd[1]: Starting A high performance web server and a reverse proxy server...
Feb 09 11:16:54 hostname systemd[1]: Started A high performance web server and a reverse proxy server.
尽管 Nginx 服务器正常运行,但输出的进程信息中包含空引号(“”“”“”),这似乎很不寻常。如果您能提供任何关于为什么这些空字符串会出现在状态输出中的见解,我将不胜感激。
编辑:
输出psauxwww|grep 320285
ps auxwww|grep 320285
www-data 320285 0.0 0.0 27284 7860 ? S Feb13 0:00 nginx: worker process
答案1
通过直接覆盖数组和后续数组来更改nginx
其进程标题。我认为这是一种有点肮脏的方法,但它最初是为 FreeBSD 开发的,必须自行在 Linux 上模拟。此代码自 2005 年以来一直没有改变。argv
environ
nginx
setproctitle
由于该字符串nginx: worker process
比原始程序名称短,因此/usr/sbin/nginx -g 'daemon on; master_process on;'
字符串的其余部分被零覆盖,nginx
但systemctl status
仍将所有多余的零显示为。我怀疑这种行为后来发生了变化,因为我没有在运行252 的 Debian 12 和运行 249 的 Ubuntu 22.04""
中观察到这种情况。systemd
systemd