Last update at :2024-06-17,Edit by888u
Some time ago, Snail conducted a random survey among netizens and found that more than 80% of webmaster users hope to realize automated operation and maintenance of websites and servers. For example, a few days ago, some netizens hoped that their servers would be restarted regularly. Whether we are individual webmasters or professional operation and maintenance personnel of companies, we need to implement automated operation and maintenance when managing and maintaining websites, because this can not only reduce our workload and improve work efficiency, but also make it more efficient. Quickly respond and automate resolution of project server issues. For example, Snail often encounters netizens who mention that the server needs to perform a certain task regularly and needs to automatically restart when there may be problems with the server. If it relies purely on manual execution, the efficiency will definitely not be as good as automation.
For example, Snail has seen that monitoring treasure provides URL callback function applications. We can use this to provide more automated operation and maintenance server work based on such functions. For example, we can use it to detect downed servers and use DNSPOD Wait for the third-party parsing tool to automatically switch to the backup server IP parsing, or Snail often sees netizens mention that there are frequent problems with the server database or WEB environment, which require manual restarting to recover. We can also use the monitoring treasure URL callback function to detect After the downtime alarm is issued, WEB services such as Nginx will be automatically restarted.
In this article, Snail will practice how to use the monitoring treasure URL callback function to detect a downed server and restart the Nginx service and restore the normal operation of the website.
First, preparations
A – We need to have a Jiankongbao (jiankongbao.com) account. If you don’t have an account, you need to register a new one.
B – The site directory where the user places the URL callback PHP page. We can find an active/available WEB environment site root directory, or we can build one ourselves. The current environment needs to support SSH2 (SSH2 installation tutorial) and PHP5. .3 or above.
C – The site/server that needs to be monitored is added to the monitoring project of Monitoring Bao.
Second, set the URL callback page and parameter acquisition
According to the picture above, we go to our monitoring treasure account and add the URL callback page. This page needs to be accessible. Here we can make development scripts for different projects based on the official document reference.
Third, deploy and edit the restart server callback script
Script address: https://soft.laozuo.org/tools/jiankongbao.zip
Here Snail also shares the script (thanks to Mr. P for technical support). Here is just an example of automatically restarting or executing SSH commands. For other in-depth uses, we need to write our own scripts.
In the jiankongbao.php file of the document, the corresponding parameters are explained. We need to find the project ID, the Token of the current callback URL, and the ROOT information of our monitoring server.
More importantly, ssh_command means that after a problem occurs with the server, we will restart the Nginx WEB service. The same can be used if we need to restart the database.
Fourth, Monitoring Treasure URL callback function experience
After snail deploys the URL callback page parameters, shut down Nginx for the monitoring server, and then wait for the monitoring prompt to be notified by mobile phone or email that the server is down, and then wait for a while to see the automatic task of restoring and restarting Nginx. . It is recommended to purchase the paid version, because it will be much better in terms of response speed, monitoring frequency and functions.
In conclusion, by monitoring the function of restarting WEB services through URL callbacks, we can also apply it to more powerful automatic operation and maintenance services, so that unattended operation and maintenance practices can be achieved.
Recommended site searches: Ministry of Industry and Information Technology domain name registration system, domain name host, game server rental, US virtual space, Hong Kong cn2 server, website domain name query, php space recommendation, Hong Kong virtual host, US free space, ip query,
发表评论