Just finished rebuilding Debian based server and it’s now been operational for 3 days.
The last two days the NGinx server has stopped working during the night. Yesterday I added it to “Monitors” and this email was sent at 5 seconds past midnight.
Monitor on apache-web-server.twin-peaks-video.com for ‘Nginx Webserver’ has detected that the service has gone down at 09/15/2023 12:05 AM
Running /usr/bin/nginx …
Which coincides with log file rotation. It’s very hard to tell if this happened during the rotation of the NGinx logs or the Virtualmin logs.
I added to Monitors " /usr/bin/nginx " (looked it up) but that did not seem to work. As soon as I started NGinx in Virtualmin, email arrived “up and running”.
Hmm… If it goes down because it can’t log then there would be no useful information in the logs? Debian 12 isn’t well tested but maybe nginx detects no log file, can’t open a new one and goes down? But can create one on start up? And that is only IF it is related to log rotation which hopefully changing the timing will detect.
I did check the .log files and all the new files are created in both /logs/nginx and /logs/virtualmin. Just checked them all and they are being written into. When I looked the timestamps were just after 12:00AM, not when I restarted NGinx this morning.
Just discovered I should be using /usr/sbin/nginx in monitor. << Would adding to monitor cause any issues with log file rotate?
I added NGinx to be Monitored. Not Apache. That was in the list but disabled.
I see where the confusion came in. apache-web-server was apart of my machine name, first used many many years ago when I ran Apache. I haven’t change the name.
No, what I am saying is why should it even be an option. Why would anyone ever want to monitor or even care about some Apache server if they are using Nginx. Unless I am wrong and you really can run both servers on the same box. I don’t use apache and I certainly don’t care yet I am still informed that it is not running
do you get any output from nginx -t → which checks nginx for configuration errors. I still do not understand why you are starting apache as well as nginx. I know I asked in another post that it is actually possible but it still seems like a big no no unless you employ other services.
Let it go, @Stegan . OP explained why the word “apache” is there, and it has nothing to do with starting or stopping Apache. (It’s the hostname of the system.)
@stegan I read the article you posted, and it does look surprisingly similar to the issue I have, but this is an area of Linux I don’t know to well. I understand the principles, but not the workings. Basically I’m afraid of messing things up! @ID10T looks like he was correct when he mentioned timing being off, but as I said, I don’t know how to change it.
I did look through Log Rotate and the Action Script of NGinx, but do not see anything time related.
There’s usually an underlying cause for why it’s restarting a bunch…it’s not the timing of the thing that’s the problem, it’s almost always the symptom.
So, you almost certainly shouldn’t be trying to make it more forgiving of rapid restarts (because that isn’t going to fix whatever is making it fail to start in the first place, you’d just be wasting your time).
Look in the nginx logs in /var/log/nginx, probably. error.log is, I believe what you want. We need to know why it doesn’t start the first time systemd tries to start it, and we don’t care about the subsequent failures and the limit on how fast it is allowed to restart.