Add /version endpoint with build metadata
- /version returns JSON with build_date and git_commit from env vars - NixOS module injects GIT_COMMIT (first 8 chars of self.rev) and BUILD_DATE (self.lastModified) into systemd service environment
This commit is contained in:
1 parent
3546e19772
commit
338d4cb34e
2 files changed
+11
No files matched your search
@@ -28,6 +28,8 @@
|
||||
let
|
||||
cfg = config.services.st-pierre;
|
||||
st-pierre-pkg = self.packages.${pkgs.stdenv.hostPlatform.system}.default;
|
||||
gitHash = if (self ? rev) then builtins.substring 0 8 self.rev else "dirty";
|
||||
lastUpdated = if (self ? lastModified) then builtins.toString self.lastModified else "0";
|
||||
in
|
||||
{
|
||||
options.services.st-pierre = {
|
||||
@@ -141,6 +143,8 @@
|
||||
EMBEDDING_BASE_URL = cfg.embeddingBaseUrl;
|
||||
EMBEDDING_MODEL = cfg.embeddingModel;
|
||||
SQLITE_PATH = builtins.toString cfg.sqlitePath;
|
||||
GIT_COMMIT = gitHash;
|
||||
BUILD_DATE = lastUpdated;
|
||||
}
|
||||
// lib.optionalAttrs (cfg.openaiApiKey != null) {
|
||||
OPENAI_API_KEY = cfg.openaiApiKey;
|
||||
|
||||
@@ -83,6 +83,13 @@ func main() {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write([]byte("ok"))
|
||||
})
|
||||
mux.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(map[string]string{
|
||||
"build_date": os.Getenv("BUILD_DATE"),
|
||||
"git_commit": os.Getenv("GIT_COMMIT"),
|
||||
})
|
||||
})
|
||||
mux.Handle("/mcp", authMiddleware(token, streamableServer))
|
||||
|
||||
httpServer := &http.Server{
|
||||
|
||||
Reference in new issue
Block a user