Skip to content
Snippets Groups Projects
Commit 8dc18fad authored by Sybren A. Stüvel's avatar Sybren A. Stüvel
Browse files

Manager: exposed version to CLI (-version) and status reports

Now the / url shows the version of Flamenco Manager that is running,
and 'flamenco-manager -version' shows that too (then stops).
parent 54a46143
No related branches found
No related tags found
No related merge requests found
...@@ -107,3 +107,9 @@ type MayKeepRunningResponse struct { ...@@ -107,3 +107,9 @@ type MayKeepRunningResponse struct {
type SettingsInMongo struct { type SettingsInMongo struct {
DepsgraphLastModified *time.Time `bson:"depsgraph_last_modified"` DepsgraphLastModified *time.Time `bson:"depsgraph_last_modified"`
} }
type StatusReport struct {
NrOfWorkers int `json:"nr_of_workers"`
NrOfTasks int `json:"nr_of_tasks"`
Version string `json:"version"`
}
...@@ -9,15 +9,11 @@ import ( ...@@ -9,15 +9,11 @@ import (
mgo "gopkg.in/mgo.v2" mgo "gopkg.in/mgo.v2"
) )
type StatusReport struct {
NrOfWorkers int `json:"nr_of_workers"`
NrOfTasks int `json:"nr_of_tasks"`
}
/** /**
* Reports the status of the manager in JSON. * Reports the status of the manager in JSON.
*/ */
func SendStatusReport(w http.ResponseWriter, r *http.Request, session *mgo.Session) { func SendStatusReport(w http.ResponseWriter, r *http.Request, session *mgo.Session,
flamenco_version string) {
log.Info(r.RemoteAddr, "Status request received") log.Info(r.RemoteAddr, "Status request received")
mongo_sess := session.Copy() mongo_sess := session.Copy()
...@@ -42,6 +38,7 @@ func SendStatusReport(w http.ResponseWriter, r *http.Request, session *mgo.Sessi ...@@ -42,6 +38,7 @@ func SendStatusReport(w http.ResponseWriter, r *http.Request, session *mgo.Sessi
statusreport := StatusReport{ statusreport := StatusReport{
worker_count, worker_count,
task_count, task_count,
flamenco_version,
} }
encoder := json.NewEncoder(w) encoder := json.NewEncoder(w)
......
...@@ -32,7 +32,7 @@ var task_update_pusher *flamenco.TaskUpdatePusher ...@@ -32,7 +32,7 @@ var task_update_pusher *flamenco.TaskUpdatePusher
var task_timeout_checker *flamenco.TaskTimeoutChecker var task_timeout_checker *flamenco.TaskTimeoutChecker
func http_status(w http.ResponseWriter, r *http.Request) { func http_status(w http.ResponseWriter, r *http.Request) {
flamenco.SendStatusReport(w, r, session) flamenco.SendStatusReport(w, r, session, FLAMENCO_VERSION)
} }
func http_register_worker(w http.ResponseWriter, r *http.Request) { func http_register_worker(w http.ResponseWriter, r *http.Request) {
...@@ -124,6 +124,7 @@ var cliArgs struct { ...@@ -124,6 +124,7 @@ var cliArgs struct {
debug bool debug bool
jsonLog bool jsonLog bool
cleanSlate bool cleanSlate bool
version bool
} }
func parseCliArgs() { func parseCliArgs() {
...@@ -131,6 +132,7 @@ func parseCliArgs() { ...@@ -131,6 +132,7 @@ func parseCliArgs() {
flag.BoolVar(&cliArgs.debug, "debug", false, "Enable debug-level logging") flag.BoolVar(&cliArgs.debug, "debug", false, "Enable debug-level logging")
flag.BoolVar(&cliArgs.jsonLog, "json", false, "Log in JSON format") flag.BoolVar(&cliArgs.jsonLog, "json", false, "Log in JSON format")
flag.BoolVar(&cliArgs.cleanSlate, "cleanslate", false, "Start with a clean slate; erases all tasks from the local MongoDB") flag.BoolVar(&cliArgs.cleanSlate, "cleanslate", false, "Start with a clean slate; erases all tasks from the local MongoDB")
flag.BoolVar(&cliArgs.version, "version", false, "Show the version of Flamenco Manager")
flag.Parse() flag.Parse()
} }
...@@ -155,6 +157,11 @@ func configLogging() { ...@@ -155,6 +157,11 @@ func configLogging() {
func main() { func main() {
parseCliArgs() parseCliArgs()
if cliArgs.version {
fmt.Println(FLAMENCO_VERSION)
return
}
configLogging() configLogging()
log.Infof("Starting Flamenco Manager version %s", FLAMENCO_VERSION) log.Infof("Starting Flamenco Manager version %s", FLAMENCO_VERSION)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment