aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-12-22 18:56:16 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-01-08 18:26:00 +0200
commiteb16296f88ce0fdb4a98a08950b58a346a6e2bd9 (patch)
tree007cd0c925705a488a053b756fc9b3f41e464118
parent1d2117596f23b8606a17f74946a229944558d3a4 (diff)
Log brep and libs version on web server startup
-rw-r--r--brep/module8
-rw-r--r--brep/module.cxx7
-rw-r--r--brep/package-version-details.cxx1
-rw-r--r--brep/repository-root3
-rw-r--r--brep/repository-root.cxx12
-rw-r--r--web/apache/service20
-rw-r--r--web/module9
7 files changed, 55 insertions, 5 deletions
diff --git a/brep/module b/brep/module
index 80a0a56..5e6a181 100644
--- a/brep/module
+++ b/brep/module
@@ -165,6 +165,14 @@ namespace brep
virtual bool
handle (request&, response&, log&);
+ virtual void
+ version (log&);
+
+ // Can be overriden by the module implementation to log version, etc.
+ //
+ virtual void
+ version () {}
+
name_values
expand_options (const name_values&);
diff --git a/brep/module.cxx b/brep/module.cxx
index 283731e..e2b99af 100644
--- a/brep/module.cxx
+++ b/brep/module.cxx
@@ -337,6 +337,13 @@ namespace brep
}
}
+ void module::
+ version (log& l)
+ {
+ log_ = &l;
+ version ();
+ }
+
// module::name_value_scanner
//
module::name_value_scanner::
diff --git a/brep/package-version-details.cxx b/brep/package-version-details.cxx
index 9bc06f6..0300b88 100644
--- a/brep/package-version-details.cxx
+++ b/brep/package-version-details.cxx
@@ -48,6 +48,7 @@ handle (request& rq, response& rs)
{
using namespace web;
using namespace web::xhtml;
+ using brep::version; // Not to confuse with module::version.
MODULE_DIAG;
diff --git a/brep/repository-root b/brep/repository-root
index 2397764..006f163 100644
--- a/brep/repository-root
+++ b/brep/repository-root
@@ -38,6 +38,9 @@ namespace brep
virtual void
init (cli::scanner&);
+ virtual void
+ version ();
+
private:
shared_ptr<package_search> package_search_;
shared_ptr<package_details> package_details_;
diff --git a/brep/repository-root.cxx b/brep/repository-root.cxx
index 7af76b2..5711109 100644
--- a/brep/repository-root.cxx
+++ b/brep/repository-root.cxx
@@ -10,6 +10,7 @@
#include <brep/types>
#include <brep/utility>
+#include <brep/version>
#include <brep/module>
#include <brep/options>
@@ -187,4 +188,15 @@ namespace brep
return false;
}
+
+ void repository_root::
+ version ()
+ {
+ MODULE_DIAG;
+
+ info << "module " << BREP_VERSION_STR
+ << ", libbrep " << LIBBREP_VERSION_STR
+ << ", libbpkg " << LIBBPKG_VERSION_STR
+ << ", libbutl " << LIBBUTL_VERSION_STR;
+ }
}
diff --git a/web/apache/service b/web/apache/service
index 32ca98d..9641a6b 100644
--- a/web/apache/service
+++ b/web/apache/service
@@ -84,18 +84,27 @@ namespace web
template <typename M>
static int
- config_finalizer (apr_pool_t*, apr_pool_t*, apr_pool_t*, server_rec*)
+ config_finalizer (apr_pool_t*, apr_pool_t*, apr_pool_t*, server_rec* s)
noexcept
{
- instance<M> ()->options_parsed_ = true;
+ auto srv (instance<M> ());
+ bool& parsed (srv->options_parsed_);
+
+ if (!parsed)
+ {
+ log l (s);
+ srv->exemplar_.version (l);
+ parsed = true;
+ }
+
return OK;
}
template <typename M>
static void
- worker_initializer (apr_pool_t*, server_rec* server) noexcept
+ worker_initializer (apr_pool_t*, server_rec* s) noexcept
{
- log l (server);
+ log l (s);
instance<M> ()->init_worker (l);
}
@@ -125,7 +134,8 @@ namespace web
add_option (const char* name, optional<std::string> value);
template <typename M>
- int handle (request& r, log& l) noexcept;
+ int
+ handle (request& r, log& l) noexcept;
private:
std::string name_;
diff --git a/web/module b/web/module
index 50cc6be..704fa6d 100644
--- a/web/module
+++ b/web/module
@@ -195,6 +195,15 @@ namespace web
options () = 0;
// During startup the web server calls this function on the module
+ // exemplar to log the module version information. It is up to the web
+ // server whether to call this function once per module implementation
+ // type. Therefore, it is expected that this function will log the same
+ // information for all the module exemplars.
+ //
+ virtual void
+ version (log&) = 0;
+
+ // During startup the web server calls this function on the module
// exemplar passing a list of configuration options. The place these
// configuration options come from is implementation-specific (normally
// a configuration file). The web server guarantees that only options