So very recently I came across a Development Request with one of my clients, more sort of an issue where they wanted to show a Maintenance Portal when there BI Application like OBIEE is unable to handle requests when the back end Database is down.
This Maintenance Portal would be mostly static, one HTML page , which would display a banner saying application is under maintenance. Something like below:
Seems simple hunh..?
Problem really was when your BI Tool, like OBIEE for e.g. is unable to handle requests or is down, it won't be able to show even a simple web page like this. Probably because the web server that came with it is also down.
Solution... Python comes to rescue!!
Recently I came to know that Python has a capability to host web pages using a light weight HTTP server which comes with it. All you have to do is run below command:
where 8000 is the port at which the Python HTTP Server will run. It will show all contents of the directory in web format from where this is run or would show an HTML page if you have Index.html file present in that folder.
So this is command line, how do we do this in a script??
Same thing as above you could invoke from a Python Script (.py). I give here a sample script which I used in my project to show Maintenance Portal and check Database for connectivity.
webserver.py
I scheduled this script on my Windows Server in Task Scheduler using below wrapper script.
Maintenance_Batch.cmd
I invoke the above wrapper script using below command:
D:\Maintenance_Portal is where my Index.html is present.
So once this script becomes active, it stops the Application Server (OBIEE in my case), Starts Maintenance Portal on port 80, keeps checking Database for connectivity every 15 minutes and as soon as it is up it Stops the Maintenance Portal and Starts the Application Server.
You could obviously tweak around the script more to achieve a custom functionality but in really a few simple steps and by using the HTTP Server provided by Python, you could very easily host a Maintenance portal of your own.
This Maintenance Portal would be mostly static, one HTML page , which would display a banner saying application is under maintenance. Something like below:
Seems simple hunh..?
Problem really was when your BI Tool, like OBIEE for e.g. is unable to handle requests or is down, it won't be able to show even a simple web page like this. Probably because the web server that came with it is also down.
Solution... Python comes to rescue!!
Recently I came to know that Python has a capability to host web pages using a light weight HTTP server which comes with it. All you have to do is run below command:
where 8000 is the port at which the Python HTTP Server will run. It will show all contents of the directory in web format from where this is run or would show an HTML page if you have Index.html file present in that folder.
So this is command line, how do we do this in a script??
Same thing as above you could invoke from a Python Script (.py). I give here a sample script which I used in my project to show Maintenance Portal and check Database for connectivity.
webserver.py
I scheduled this script on my Windows Server in Task Scheduler using below wrapper script.
Maintenance_Batch.cmd
I invoke the above wrapper script using below command:
D:\Maintenance_Portal is where my Index.html is present.
So once this script becomes active, it stops the Application Server (OBIEE in my case), Starts Maintenance Portal on port 80, keeps checking Database for connectivity every 15 minutes and as soon as it is up it Stops the Maintenance Portal and Starts the Application Server.
You could obviously tweak around the script more to achieve a custom functionality but in really a few simple steps and by using the HTTP Server provided by Python, you could very easily host a Maintenance portal of your own.