Auto Restart The Server if Website Fails

Ali cloud ECS server, some times inexplicable to restart their own. So build a boot log to record when it restart its own.
But this is not enough, Because a few days ago the Ali cloud server appears a strange fault – My VPS web server does not find any problem, but it is can not connect to the database,Want to restart the related services are always reported memory errors, and finally only restart the server manually.
Finally, the most worried before about — the website failed but we cannot detection and treatment timely, because the Ali cloud does not seem to automatically restart at this time. Therefore, it is necessary to build a program, allows the server to restart by self.
Reference to the following code (is a useful code)↓, Now the server achieve a page once every 20 minutes, if the normal exit, else auto record and repair & restart the server.

wget ifok
set “file=ifok.txt”
for /f “usebackq tokens=1* delims=:” %%a in (“%file%”) do (
set “%%a=%%b”
)
for /f “usebackq delims=:” %%a in (“%file%”) do if %%a == ifok goto ifok
echo error1-%date%-%time%>>ifoklog.txt
restart
:ifok
exit

Deployment is complete, and now waiting to see the treatment effect.
By the way to see the longest for do not restart of Ali cloud ECS server.

分享到: 更多

One thought on “Auto Restart The Server if Website Fails

  1. Natalie

    Hi my name is Natalie and I just wanted to send you a quick message here instead of calling you. I discovered your Auto Restart The Server if Website Fails | AAOAA website and noticed you could have a lot more traffic. I have found that the key to running a successful website is making sure the visitors you are getting are interested in your subject matter. There is a company that you can get keyword targeted visitors from and they let you try the service for free for 7 days. I managed to get over 300 targeted visitors to day to my site. Visit them here: http://AdHideBy.AAOAA.com

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *