Skip to content

Commit 76f4192

Browse files
authored
Merge pull request #163 from sympy/status-endpoint
Add status endpoint to check if app is running
2 parents 7169fe6 + 6f6a48c commit 76f4192

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ deploy:
5858
after_deploy:
5959
- pip install requests
6060
- python bin/update_status_on_pr.py
61+
- status_code=$(curl --write-out %{http_code} --silent --output /dev/null https://$TRAVIS_BRANCH-dot-sympy-live-hrd.appspot.com/status)
62+
- echo "App status code => $status_code"
63+
- if [ "$status_code" != "200" ]; then travis_terminate; fi
6164

6265
env:
6366
global:

app/shell.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,12 +829,22 @@ def get(self):
829829

830830
self.response.out.write("Your queries have been deleted.")
831831

832+
832833
class RedirectHandler(webapp.RedirectHandler):
833834
"""Redirects deprecated pages to the frontpage."""
834835

835836
def get(self):
836837
self.redirect('/', permanent=True)
837838

839+
840+
class StatusHandler(webapp.RequestHandler):
841+
"""Status endpoint to check if the app is running or not."""
842+
843+
def get(self):
844+
self.response.headers['Content-Type'] = 'application/json'
845+
self.response.out.write(json.dumps({"status": "ok"}))
846+
847+
838848
application = webapp.WSGIApplication([
839849
('/', FrontPageHandler),
840850
('/evaluate', EvaluateHandler),
@@ -845,4 +855,5 @@ def get(self):
845855
('/shellmobile', RedirectHandler),
846856
('/shelldsi', RedirectHandler),
847857
('/helpdsi', RedirectHandler),
858+
('/status', StatusHandler),
848859
], debug=_DEBUG)

0 commit comments

Comments
 (0)