You are not logged in.
After a reboot, nginx takes a bit apparently and fails to start:
journalctl -b -u nginx
May 04 23:04:21 xxx systemd[1]: Starting A high performance web server and a reverse proxy server...
May 04 23:05:52 xxx systemd[1]: nginx.service: start operation timed out. Terminating.
May 04 23:05:52 xxx systemd[1]: nginx.service: Failed with result 'timeout'.
May 04 23:05:52 xxx systemd[1]: Failed to start A high performance web server and a reverse proxy server.
If I start it manually then when I login (it's a server), then it starts without a problem. It seems it's waiting on something not available yet at startup. Are we sure the .service dependencies are correctly setup? (I'm using the .service provided by arch)
May 04 23:04:21 xxx systemd[1]: Starting A high performance web server and a reverse proxy server...
May 04 23:05:52 xxx systemd[1]: nginx.service: start operation timed out. Terminating.
May 04 23:05:52 xxx systemd[1]: nginx.service: Failed with result 'timeout'.
May 04 23:05:52 xxx systemd[1]: Failed to start A high performance web server and a reverse proxy server.
---> May 04 23:19:43 xxx systemd[1]: Starting A high performance web server and a reverse proxy server...<---
May 04 23:19:43 xxx systemd[1]: Started A high performance web server and a reverse proxy server.
May 04 23:26:35 xxx nginx[19110]: xxx nginx: 51.15.251.143 - - [04/May/2023:23:26:35 +0200] "GET / HTTP/1.1" 301 169 "-" "-"
May 04 23:28:04 xxx nginx[19110]: xxx nginx: 193.35.18.65 - - [04/May/2023:23:28:04 +0200] "GET / HTTP/1.1" 444 0 "-" "-"
Last edited by Tid91 (2023-05-09 22:19:38)
Offline
The network device probably is not yet ready at that point (why here).
Delay the server start or try the 'network-online.target' (that is 'blocking/waiting' until a connection is available).
Last edited by Maniaxx (2023-05-05 06:54:30)
sys2064
Offline
Normally, with the `After` clause, it should waiting for `network-online`, shouldn't it?
[Unit]
Description=A high performance web server and a reverse proxy server
After=network.target network-online.target nss-lookup.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
PrivateDevices=yes
SyslogLevel=err
ExecStart=/usr/bin/nginx -g 'pid /run/nginx.pid; error_log stderr;'
ExecReload=/usr/bin/nginx -s reload
KillMode=mixed
[Install]
WantedBy=multi-user.target
Offline
Yes, but being 'online' probably doesn't necessarily mean that all requirements of your nginx server are met. There might be additional interfaces involved, etc. Or maybe the interface goes up/down several times on bootup. Only the logs might know.
I would simply add a 'Restart=' to the unit so it tries multiple times to bring the server up.
sys2064
Offline
I think I solved with the following override.conf (in /etc/systemd/system/nginx.d)
[Unit]
Wants=network-online.target
Offline