Merge pull request #31 from keitaroinc/maintainence-mode
Add setup for maintenance mode for CKAN
This commit is contained in:
commit
538088a5de
|
@ -2,6 +2,9 @@
|
||||||
# Information about how it works: https://github.com/okfn/ckanext-envvars
|
# Information about how it works: https://github.com/okfn/ckanext-envvars
|
||||||
# Note that variables here take presedence over build/up time variables in .env
|
# Note that variables here take presedence over build/up time variables in .env
|
||||||
|
|
||||||
|
# Set to true to disable CKAN from starting and serve a maintenance page
|
||||||
|
MAINTENANCE_MODE=false
|
||||||
|
|
||||||
# General Settings
|
# General Settings
|
||||||
CKAN_SITE_ID=default
|
CKAN_SITE_ID=default
|
||||||
CKAN_SITE_URL=http://localhost:5000
|
CKAN_SITE_URL=http://localhost:5000
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
solrconfig-2.8.6.xml
|
|
@ -0,0 +1,9 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Maintenance</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Maintenance</h1>
|
||||||
|
<p>Our data portal is currently in maintenance, please try in a while.</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,9 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Maintenance</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Maintenance</h1>
|
||||||
|
<p>Our data portal is currently in maintenance, please try in a while.</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,22 @@
|
||||||
|
from SimpleHTTPServer import SimpleHTTPRequestHandler
|
||||||
|
from BaseHTTPServer import HTTPServer
|
||||||
|
from SocketServer import ThreadingMixIn
|
||||||
|
import os
|
||||||
|
|
||||||
|
PORT = 5000
|
||||||
|
|
||||||
|
web_dir = os.path.join(os.path.dirname(__file__))
|
||||||
|
os.chdir(web_dir)
|
||||||
|
|
||||||
|
Handler = SimpleHTTPRequestHandler
|
||||||
|
|
||||||
|
|
||||||
|
class MaintenanceServer(ThreadingMixIn, HTTPServer):
|
||||||
|
"""Handle requests in a separate thread."""
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
httpd = MaintenanceServer(("0.0.0.0", PORT), Handler)
|
||||||
|
print("Starting maintenance mode")
|
||||||
|
httpd.serve_forever()
|
||||||
|
|
|
@ -18,6 +18,9 @@ UWSGI_OPTS="--socket /tmp/uwsgi.sock --uid 92 --gid 92 --http :5000 --master --e
|
||||||
# Run the prerun script to init CKAN and create the default admin user
|
# Run the prerun script to init CKAN and create the default admin user
|
||||||
python prerun.py
|
python prerun.py
|
||||||
|
|
||||||
|
# Check if we are in maintenance mode and if yes serve the maintenance pages
|
||||||
|
if [ "$MAINTENANCE_MODE" = true ]; then PYTHONUNBUFFERED=1 python maintenance/serve.py; fi
|
||||||
|
|
||||||
# Run any after prerun/init scripts provided by images extending this one
|
# Run any after prerun/init scripts provided by images extending this one
|
||||||
if [[ -d "${APP_DIR}/docker-afterinit.d" ]]
|
if [[ -d "${APP_DIR}/docker-afterinit.d" ]]
|
||||||
then
|
then
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Maintenance</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Maintenance</h1>
|
||||||
|
<p>Our data portal is currently in maintenance, please try in a while.</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,9 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Maintenance</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Maintenance</h1>
|
||||||
|
<p>Our data portal is currently in maintenance, please try in a while.</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,22 @@
|
||||||
|
from SimpleHTTPServer import SimpleHTTPRequestHandler
|
||||||
|
from BaseHTTPServer import HTTPServer
|
||||||
|
from SocketServer import ThreadingMixIn
|
||||||
|
import os
|
||||||
|
|
||||||
|
PORT = 5000
|
||||||
|
|
||||||
|
web_dir = os.path.join(os.path.dirname(__file__))
|
||||||
|
os.chdir(web_dir)
|
||||||
|
|
||||||
|
Handler = SimpleHTTPRequestHandler
|
||||||
|
|
||||||
|
|
||||||
|
class MaintenanceServer(ThreadingMixIn, HTTPServer):
|
||||||
|
"""Handle requests in a separate thread."""
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
httpd = MaintenanceServer(("0.0.0.0", PORT), Handler)
|
||||||
|
print("Starting maintenance mode")
|
||||||
|
httpd.serve_forever()
|
||||||
|
|
|
@ -18,6 +18,9 @@ UWSGI_OPTS="--socket /tmp/uwsgi.sock --uid 92 --gid 92 --http :5000 --master --e
|
||||||
# Run the prerun script to init CKAN and create the default admin user
|
# Run the prerun script to init CKAN and create the default admin user
|
||||||
python prerun.py
|
python prerun.py
|
||||||
|
|
||||||
|
# Check if we are in maintenance mode and if yes serve the maintenance pages
|
||||||
|
if [ "$MAINTENANCE_MODE" = true ]; then PYTHONUNBUFFERED=1 python maintenance/serve.py; fi
|
||||||
|
|
||||||
# Run any after prerun/init scripts provided by images extending this one
|
# Run any after prerun/init scripts provided by images extending this one
|
||||||
if [[ -d "${APP_DIR}/docker-afterinit.d" ]]
|
if [[ -d "${APP_DIR}/docker-afterinit.d" ]]
|
||||||
then
|
then
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Maintenance</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Maintenance</h1>
|
||||||
|
<p>Our data portal is currently in maintenance, please try in a while.</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,9 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Maintenance</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Maintenance</h1>
|
||||||
|
<p>Our data portal is currently in maintenance, please try in a while.</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,19 @@
|
||||||
|
from http.server import ThreadingHTTPServer, SimpleHTTPRequestHandler
|
||||||
|
import os
|
||||||
|
|
||||||
|
PORT = 5000
|
||||||
|
|
||||||
|
web_dir = os.path.join(os.path.dirname(__file__))
|
||||||
|
os.chdir(web_dir)
|
||||||
|
|
||||||
|
|
||||||
|
def run(server_class=ThreadingHTTPServer, handler_class=SimpleHTTPRequestHandler):
|
||||||
|
server_address = ("0.0.0.0", PORT)
|
||||||
|
httpd = server_class(server_address, handler_class)
|
||||||
|
print("Starting maintenance mode")
|
||||||
|
httpd.serve_forever()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
run()
|
||||||
|
|
|
@ -18,6 +18,9 @@ UWSGI_OPTS="--socket /tmp/uwsgi.sock --uid ckan --gid ckan --http :5000 --master
|
||||||
# Run the prerun script to init CKAN and create the default admin user
|
# Run the prerun script to init CKAN and create the default admin user
|
||||||
python prerun.py
|
python prerun.py
|
||||||
|
|
||||||
|
# Check if we are in maintenance mode and if yes serve the maintenance pages
|
||||||
|
if [ "$MAINTENANCE_MODE" = true ]; then PYTHONUNBUFFERED=1 python maintenance/serve.py; fi
|
||||||
|
|
||||||
# Run any after prerun/init scripts provided by images extending this one
|
# Run any after prerun/init scripts provided by images extending this one
|
||||||
if [[ -d "${APP_DIR}/docker-afterinit.d" ]]
|
if [[ -d "${APP_DIR}/docker-afterinit.d" ]]
|
||||||
then
|
then
|
||||||
|
|
Loading…
Reference in New Issue