-
-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #630 from kobotoolbox/kobotoolbox/kobo-docker#301-…
…expose-port-8001 Listen on port 8001 with uWSGI and `EXPOSE` that
- Loading branch information
Showing
5 changed files
with
68 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env python | ||
|
||
""" | ||
Per kobotoolbox/kobo-docker#301, we have changed the uWSGI port to 8001. This | ||
provides a helpful message to anyone still trying to use port 8000 | ||
""" | ||
|
||
import BaseHTTPServer | ||
import sys | ||
|
||
class Handler(BaseHTTPServer.BaseHTTPRequestHandler): | ||
def do_GET(self): | ||
self.send_response(503) | ||
self.end_headers() | ||
self.wfile.write( | ||
'Your development environment is trying to connect to the KoBoCAT ' | ||
'container on port 8000 instead of 8001. Please change this. See ' | ||
'https://github.com/kobotoolbox/kobo-docker/issues/301 ' | ||
'for more details.' | ||
) | ||
|
||
server_address = ('', int(sys.argv[1])) | ||
httpd = BaseHTTPServer.HTTPServer(server_address, Handler) | ||
httpd.serve_forever() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
source /etc/profile | ||
|
||
# Per kobotoolbox/kobo-docker#301, we have changed the uWSGI port to 8001. This | ||
# provides a helpful message to anyone still trying to use port 8000 | ||
|
||
if [[ "${KOBOCAT_WEB_SERVER,,}" == "uwsgi" ]] | ||
then | ||
exec /usr/local/bin/uwsgi --uid "${UWSGI_USER}" --socket :8000 --wsgi-file "${KOBOCAT_SRC_DIR}/docker/wrong_port_warning.wsgi" | ||
else | ||
exec "${KOBOCAT_SRC_DIR}/docker/dev_wrong_port_warning.py" 8000 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Per kobotoolbox/kobo-docker#301, we have changed the uWSGI port to 8001. This | ||
# provides a helpful message to anyone still trying to use port 8000. | ||
# Based upon | ||
# https://uwsgi-docs.readthedocs.io/en/latest/WSGIquickstart.html#the-first-wsgi-application | ||
|
||
html_response = b''' | ||
<html> | ||
<head><title>System configuration error</title></head> | ||
<body> | ||
<h1>System configuration error</h1> | ||
<p>Please contact the administrator of this server.</p> | ||
<p style="border: 0.1em solid black; padding: 0.5em">If you are the | ||
administrator of this server: KoBoCAT received this request on port 8000, when | ||
8001 should have been used. Please see | ||
<a href="https://github.com/kobotoolbox/kobo-docker/issues/301"> | ||
https://github.com/kobotoolbox/kobo-docker/issues/301</a> for more | ||
information.</p> | ||
<p>Thanks for using KoBoToolbox.</p></body></html> | ||
''' | ||
|
||
def application(env, start_response): | ||
start_response('503 Service Unavailable', [('Content-Type','text/html')]) | ||
return [html_response] |