How to make application auto-run again after power failure?

Hello,

I have a OpenSUSE 15.0 server which running nginx with multiple IPs. I met two times power failure in this month because of data center 's power supply fire. When the power came back, I found the server auto reboot-itself but without nginx running.

systemctl enable nginx

doesn’t work. I don’t know why. I have to login to this server and manually start nginx and other app.

Can someone tell me a good way to make the nginx auto run again after power failure? Thank you.

:wink:

Immediately after a reboot, show


systemctl status nginx

FWIW, enabling a service is not enough, it needs to be started, too:


systemctl start nginx.service

Typically the UPS software you should have installed should support executing special commands including starting services.

But,
There may be a specific problem that is preventing your nginx from starting…
Perhaps look at your bootlog for the specific session that suffered the power failure as well as the bootlog for the service start failirue

For the following command, you can specify any previous bootlog by changing the** n **which a number

journalctl -b -**n**

TSU

Thank you guys.

  1. UPS is supplied by data center. I think it is only for the whole rack, not for my dedicated server.

I have checked reboot log, maybe I don’t understand all of it. It looks no special, just normal starting the server.
And the nginx configurations have no conflict.

I can manually “systemctl start nginx”

It looks so strange.

So, is there a way to monitor nginx, when it is not running, the system will start it? Thank you

Post the following for your machine so we can verify your configuration

systemctl status nginx

The following should display all system log entries for your nginx service for a specified bootlog (you’ll have to know how many times your system might have rebooted since the power failure). The following assumes that the current session is the second time you’ve rebooted your machine since your power failure

journalctl -b -2 -u nginx.service

Post your results of the above if you need help interpreting the entries.

TSU