This repository has been archived by the owner on Apr 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3862fa7
commit 3967c57
Showing
5 changed files
with
50 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import logging | ||
|
||
logger = logging.getLogger('servicebook') | ||
__version__ = "0.1" |
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,15 @@ | ||
from serviceweb.tests.support import BaseTest | ||
from serviceweb import __version__ | ||
|
||
|
||
class HBTest(BaseTest): | ||
def test_version(self): | ||
info = self.app.get('/__version__').json | ||
self.assertEqual(info['version'], __version__) | ||
|
||
def test_lbheartbeat(self): | ||
self.app.get('/__lbheartbeat__', status=200) | ||
|
||
def test_heartbeat(self): | ||
resp = self.app.get('/__heartbeat__', status=200).json | ||
self.assertTrue(resp['database']) |
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,29 @@ | ||
import subprocess | ||
import json | ||
from flask import Blueprint, render_template, jsonify, g | ||
from serviceweb import __version__ | ||
|
||
|
||
heartbeat = Blueprint('heartbeat', __name__) | ||
|
||
|
||
@heartbeat.route('/__version__') | ||
def _version(): | ||
commit = subprocess.check_output(["git", "describe", "--always"]) | ||
resp = render_template('version.json', version=__version__, | ||
commit=str(commit.strip(), 'utf8')) | ||
data = json.loads(resp) | ||
return jsonify(data) | ||
|
||
|
||
@heartbeat.route('/__lbheartbeat__') | ||
def _lbheartbeat(): | ||
return '' | ||
|
||
|
||
@heartbeat.route('/__heartbeat__') | ||
def _heartbeat(): | ||
results = {} | ||
users = g.db.get_entries('user') | ||
results['database'] = len(users) > 0 | ||
return jsonify(results) |
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