在 Discourse Docker 容器中重启 nginx 的正确方法是什么?
该 Docker 容器似乎运行的是 Debian 10,但使用常规的 systemd 方式重启 nginx 失败了。
[root@osestaging1 discourse]# ./launcher enter discourse_ose
root@osestaging1-discourse-ose:/var/www/discourse# cat /etc/issue
Debian GNU/Linux 10 \n \l
root@osestaging1-discourse-ose:/var/www/discourse# systemctl restart nginx
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
root@osestaging1-discourse-ose:/var/www/discourse#
看起来有一个 init.d 脚本,但运行它也会失败。日志显示是因为无法绑定到一个已被占用的地址。
root@osestaging1-discourse-ose:/etc/nginx/conf.d# /etc/init.d/nginx restart
[FAIL] Restarting nginx: nginx failed!
root@osestaging1-discourse-ose:/etc/nginx/conf.d# tail /var/log/nginx/error.log
2019/11/12 10:32:45 [emerg] 1123#1123: bind() to unix:/shared/nginx.http.sock failed (98: Address already in use)
2019/11/12 10:32:45 [emerg] 1123#1123: bind() to unix:/shared/nginx.http.sock failed (98: Address already in use)
2019/11/12 10:32:45 [emerg] 1123#1123: bind() to unix:/shared/nginx.http.sock failed (98: Address already in use)
2019/11/12 10:32:45 [emerg] 1123#1123: bind() to unix:/shared/nginx.http.sock failed (98: Address already in use)
2019/11/12 10:32:45 [emerg] 1123#1123: bind() to unix:/shared/nginx.http.sock failed (98: Address already in use)
2019/11/12 10:32:45 [emerg] 1123#1123: still could not bind()
2019/11/12 10:32:47 [emerg] 1127#1127: bind() to unix:/shared/nginx.http.sock failed (98: Address already in use)
2019/11/12 10:32:47 [emerg] 1127#1127: bind() to unix:/shared/nginx.http.sock failed (98: Address already in use)
2019/11/12 10:32:47 [emerg] 1127#1127: bind() to unix:/shared/nginx.http.sock failed (98: Address already in use)
2019/11/12 10:32:47 [emerg] 1127#1127: bind() to unix:/shared/nginx.http.sock failed (98: Address already in use)
确实,nginx 已经在运行了。
root@osestaging1-discourse-ose:/etc/nginx/conf.d# ps -ef | grep -i nginx
root 46 40 0 10:19 ? 00:00:00 runsv nginx
root 1174 46 1 10:33 ? 00:00:00 /usr/sbin/nginx
root 1177 108 0 10:33 pts/1 00:00:00 grep -i nginx
root@osestaging1-discourse-ose:/etc/nginx/conf.d#
正确关闭上述 nginx 进程并重新启动它的方法是什么?