为什么 nginx docker 容器被 Systemd 停止了?

为什么 nginx docker 容器被 Systemd 停止了?

今天,我在 Ubuntu 20.04.6 LTS 服务器上以容器形式运行的 Nginx 服务遇到了一个问题。该服务处于停止状态,我不得不手动重启它。

我附上了系统日志的一个片段以供参考。看来有几项服务已自动重启,但 Nginx 无法启动。我们手动重启了该服务。

有人能解释一下为什么 Nginx 服务停止并且没有自行重新启动吗? 我也渴望了解如何防止将来出现类似情况。

非常感谢您的见解和建议。

Feb 28 06:44:08 elephantus systemd[1]: Starting Daily apt upgrade and clean activities...
Feb 28 06:44:13 elephantus systemd[1]: Reloading.
Feb 28 06:44:14 elephantus systemd[1]: Stopping Network Time Synchronization...
Feb 28 06:44:14 elephantus systemd[1]: systemd-timesyncd.service: Succeeded.
Feb 28 06:44:14 elephantus systemd[1]: Stopped Network Time Synchronization.
Feb 28 06:44:14 elephantus systemd[1]: Starting Network Time Synchronization...
Feb 28 06:44:14 elephantus systemd[1]: Started Network Time Synchronization.
Feb 28 06:44:14 elephantus systemd-timesyncd[343836]: Initial synchronization to time server 169.254.169.123:123 (169.254.169.123).
Feb 28 06:44:14 elephantus systemd[1]: Reexecuting.
Feb 28 06:44:14 elephantus kernel: [8457879.332950] systemd[1]: systemd 245.4-4ubuntu3.23 running in system mode. (+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN2 -IDN +PCRE2 default-hierarchy=hybrid)
Feb 28 06:44:14 elephantus kernel: [8457879.333021] systemd[1]: Detected virtualization xen.
Feb 28 06:44:14 elephantus kernel: [8457879.333027] systemd[1]: Detected architecture x86-64.
Feb 28 06:44:14 elephantus systemd[1]: Starting Refresh fwupd metadata and update motd...
Feb 28 06:44:14 elephantus systemd[1]: Condition check resulted in OpenVSwitch configuration for cleanup being skipped.
Feb 28 06:44:14 elephantus systemd[1]: systemd-networkd-wait-online.service: Succeeded.
Feb 28 06:44:14 elephantus systemd[1]: Stopped Wait for Network to be Configured.
Feb 28 06:44:14 elephantus systemd[1]: Stopping Wait for Network to be Configured...
Feb 28 06:44:14 elephantus systemd[1]: Stopping Network Service...
Feb 28 06:44:14 elephantus systemd[343880]: fwupd-refresh.service: Failed to determine user credentials: No such process
Feb 28 06:44:14 elephantus systemd[343880]: fwupd-refresh.service: Failed at step USER spawning /usr/bin/fwupdmgr: No such process
Feb 28 06:44:14 elephantus systemd[1]: fwupd-refresh.service: Main process exited, code=exited, status=217/USER
Feb 28 06:44:14 elephantus systemd[1]: fwupd-refresh.service: Failed with result 'exit-code'.
Feb 28 06:44:14 elephantus systemd[1]: Failed to start Refresh fwupd metadata and update motd.
Feb 28 06:44:14 elephantus systemd[1]: systemd-networkd.service: Succeeded.
Feb 28 06:44:14 elephantus systemd[1]: Stopped Network Service.
Feb 28 06:44:14 elephantus systemd[1]: Starting Network Service...


Feb 28 06:44:41 elephantus systemd[1]: Stopping Login Service...
Feb 28 06:44:41 elephantus systemd[1]: systemd-logind.service: Succeeded.
Feb 28 06:44:41 elephantus systemd[1]: Stopped Login Service.
Feb 28 06:44:41 elephantus systemd[1]: Condition check resulted in Load Kernel Module drm being skipped.
Feb 28 06:44:41 elephantus systemd[1]: Starting Login Service...
Feb 28 06:44:42 elephantus systemd[1]: Started Login Service.
Feb 28 06:44:42 elephantus systemd[1]: Reloading.
Feb 28 06:44:43 elephantus systemd[1]: message repeated 2 times: [ Reloading.]
Feb 28 06:44:43 elephantus systemd[1]: Stopping nginx container...
Feb 28 06:44:44 elephantus nginx[329832]: 2024/02/28 06:44:44 [notice] 1#1: signal 3 (SIGQUIT) received, shutting down
Feb 28 06:44:44 elephantus nginx[329832]: 2024/02/28 06:44:44 [notice] 21#21: gracefully shutting down
Feb 28 06:44:44 elephantus nginx[329832]: 2024/02/28 06:44:44 [notice] 21#21: exiting
Feb 28 06:44:44 elephantus nginx[329832]: 2024/02/28 06:44:44 [notice] 21#21: exit
Feb 28 06:44:44 elephantus nginx[329832]: 2024/02/28 06:44:44 [notice] 1#1: signal 17 (SIGCHLD) received from 21
Feb 28 06:44:44 elephantus nginx[329832]: 2024/02/28 06:44:44 [notice] 1#1: worker process 21 exited with code 0
Feb 28 06:44:44 elephantus nginx[329832]: 2024/02/28 06:44:44 [notice] 1#1: exit

2024/02/28 07:56:35 [emerg] 1#1: host not found in upstream "grafana" in /etc/nginx/conf.d/grafana.conf:15
nginx: [emerg] host not found in upstream "grafana" in /etc/nginx/conf.d/grafana.conf:15

重启后,

2024/02/28 07:58:02 [notice] 1#1: using the "epoll" event method
2024/02/28 07:58:02 [notice] 1#1: nginx/1.23.0
2024/02/28 07:58:02 [notice] 1#1: built by gcc 11.2.1 20220219 (Alpine 11.2.1_git20220219)
2024/02/28 07:58:02 [notice] 1#1: OS: Linux 5.15.0-1049-aws
2024/02/28 07:58:02 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2024/02/28 07:58:02 [notice] 1#1: start worker processes
2024/02/28 07:58:02 [notice] 1#1: start worker process 21  

相关内容