Add /version endpoint with git hash for deploy verification
This commit is contained in:
parent
e9bef9982d
commit
1ebfb5a8aa
2 changed files with 25 additions and 0 deletions
|
|
@ -2,6 +2,7 @@ def includeme(config):
|
|||
config.add_static_view("static", "static", cache_max_age=3600)
|
||||
config.add_route("favicon", "/favicon.ico")
|
||||
config.add_route("robots", "/robots.txt")
|
||||
config.add_route("version", "/version")
|
||||
|
||||
# Sitemap and feed routes
|
||||
config.add_route("sitemap", "/sitemap.xml")
|
||||
|
|
|
|||
24
make_post_sell/views/version.py
Normal file
24
make_post_sell/views/version.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import subprocess
|
||||
|
||||
from pyramid.response import Response
|
||||
from pyramid.view import view_config
|
||||
|
||||
# Capture git hash once at process start.
|
||||
try:
|
||||
GIT_HASH = (
|
||||
subprocess.check_output(
|
||||
["git", "rev-parse", "--short", "HEAD"],
|
||||
stderr=subprocess.DEVNULL,
|
||||
)
|
||||
.decode()
|
||||
.strip()
|
||||
)
|
||||
except Exception:
|
||||
GIT_HASH = "unknown"
|
||||
|
||||
VERSION = "1.1.5"
|
||||
|
||||
|
||||
@view_config(route_name="version", renderer="json")
|
||||
def version(request):
|
||||
return {"version": VERSION, "hash": GIT_HASH}
|
||||
Loading…
Add table
Add a link
Reference in a new issue