Improve the logged version string and add clboss-status "info"

The logged version now looks like:
plugin-clboss: clboss v0.13.2 (v0.13.2-rc1-3-g44832e2)

A new "info" chunk is added to clboss-status:
   "info": {
      "version": "v0.13.2",
      "git_commit_hash": "44832e2258069641a6149bdc90b7e5fc12219f77",
      "git_describe": "v0.13.2-rc1-3-g44832e2"
   },
This commit is contained in:
Ken Sedgwick 2024-07-19 13:22:22 -07:00
parent 11a16bb83c
commit 44476241d1
4 changed files with 36 additions and 3 deletions

1
.gitignore vendored
View file

@ -36,3 +36,4 @@ auxdir
test_*
!test_*.cpp
!test_*.c
/commit_hash.h

View file

@ -1,3 +1,4 @@
#include"commit_hash.h"
#include"Boss/Mod/Initiator.hpp"
#include"Boss/Mod/Rpc.hpp"
#include"Boss/Msg/CommandRequest.hpp"
@ -7,6 +8,8 @@
#include"Boss/Msg/Init.hpp"
#include"Boss/Msg/ManifestOption.hpp"
#include"Boss/Msg/Option.hpp"
#include"Boss/Msg/ProvideStatus.hpp"
#include"Boss/Msg/SolicitStatus.hpp"
#include"Boss/Signer.hpp"
#include"Boss/log.hpp"
#include"Ev/ThreadPool.hpp"
@ -144,6 +147,19 @@ public:
{
assert(open_rpc_socket);
bus.subscribe< Msg::SolicitStatus
>([this](Msg::SolicitStatus const&) {
auto info = Json::Out()
.start_object()
.field( "version", "v" + std::string(PACKAGE_VERSION) )
.field( "git_commit_hash", std::string(GIT_COMMIT_HASH) )
.field( "git_describe", std::string(GIT_DESCRIBE) )
.end_object()
;
return bus.raise(Msg::ProvideStatus{
"info", std::move(info)
});
});
bus.subscribe<Boss::Msg::CommandRequest>([this](Boss::Msg::CommandRequest const& c) {
if (c.command != "init")
return Ev::lift();
@ -219,8 +235,10 @@ public:
}
return Boss::log( bus, Info
, "%s"
, PACKAGE_STRING
, "%s v%s (%s)"
, PACKAGE_NAME
, PACKAGE_VERSION
, GIT_DESCRIBE
)
+ std::move(pre_act)
/* Now construct the RPC socket. */

View file

@ -566,7 +566,9 @@ EXTRA_DIST = \
reproducible/README.md \
reproducible/build.sh \
reproducible/continue.sh \
reproducible/manifest.scm.template
reproducible/manifest.scm.template \
generate_commit_hash.sh \
commit_hash.h
AM_CXXFLAGS = -Wall -Werror $(PTHREAD_CFLAGS) $(libev_CFLAGS) $(SQLITE3_CFLAGS) $(CURL_CFLAGS) $(CLBOSS_CXXFLAGS)
LDADD = libclboss.la $(PTHREAD_LIBS) $(libev_LIBS) $(SQLITE3_LIBS) $(CURL_LIBS)
@ -668,3 +670,11 @@ CLEANFILES = $(noinst_SCRIPTS)
create-tarball: create-tarball.in Makefile
sed -e 's/[@]PACKAGE_VERSION[@]/$(PACKAGE_VERSION)/' < $(srcdir)/create-tarball.in > create-tarball
chmod +x create-tarball
BUILT_SOURCES = commit_hash.h
CLEANFILES += commit_hash.h
commit_hash.h:
./generate_commit_hash.sh
clboss libclboss.la: $(BUILT_SOURCES)

4
generate_commit_hash.sh Executable file
View file

@ -0,0 +1,4 @@
# generate_commit_hash.sh
echo "#pragma once" > commit_hash.h
echo "#define GIT_COMMIT_HASH \"$(git rev-parse HEAD)\"" >> commit_hash.h
echo "#define GIT_DESCRIBE \"$(git describe --tags --long --always --match=v*.* --dirty)\"" >> commit_hash.h