I was troubled by some server glitch since couple of days. I am currently setting up a basic WordPress website for a new start-up Safety Professionals. Their webserver was on DIGITAL OCEAN 5$ plan since they are just starting their business. I configured some basic stuff such as Apache, PhpMyAdmin and emacs!! on the webserver.
The last one EMACS is just for fun as I love using that.
Nevertheless, while configuring the website I ran into a strange error!
After googling around a bit I came to know that it is all happening due to load balancing issue. Since it was not feasible for me to move to ngnix. I got stuck with only one choice of upgrading the server, which I did not want as I thought it would be cool to play with the test cases and random stuff on a low cost server and not the HIGH POWERED one! 😛
But when fate ordains……
So eventually I got stuck up!!
But then something miraculous happened!!
I was scraping a website using Python and a idea stuck my mind and I told myself If I could just check using Python Script that whether or not my website is up or not! I could run a script to restart both apache and mysql-server which will solve the problem. YA YA SERVER LOAD WILL INCREASE!! but at least for the time being I’ll be able to test what I wanted to 😛 😛
So I wrote the following 9 line python script :
os.system(“sudo service apache2 restart”);
os.system(“sudo service mysql restart”);
All it does is that it analyses whether or not my website is up! If it is up then NOTHING if not then the following set of commands will be executed. After this I placed the following script in the crontab… and VOILA! IT WORKS!
Eventually this script has saved my ass for the time being. Also the following problem opened up the insight of load balancing to me and server management of course!
Well that’s it for now! Till the next time ADIOS!