From 888569d0701ad2a0214f71c9ac37fe52af26937c Mon Sep 17 00:00:00 2001 From: Harvey Kandola Date: Thu, 10 Aug 2017 12:38:05 +0100 Subject: [PATCH] setup mode message & license change callback params --- domain/setting/endpoint.go | 18 +++++++++++------- server/server.go | 12 ++++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/domain/setting/endpoint.go b/domain/setting/endpoint.go index 1f7401e4..41a76646 100644 --- a/domain/setting/endpoint.go +++ b/domain/setting/endpoint.go @@ -148,33 +148,37 @@ func (h *Handler) SetLicense(w http.ResponseWriter, r *http.Request) { lj := licenseJSON{} x := licenseXML{Key: "", Signature: ""} - err = xml.Unmarshal([]byte(config), &x) - if err == nil { + err1 := xml.Unmarshal([]byte(config), &x) + if err1 == nil { lj.Key = x.Key lj.Signature = x.Signature } else { h.Runtime.Log.Error("failed to XML unmarshal EDITION-LICENSE", err) } - j, err := json.Marshal(lj) + j, err2 := json.Marshal(lj) js := "{}" - if err == nil { + if err2 == nil { js = string(j) + } else { + h.Runtime.Log.Error("failed to JSON marshal EDITION-LICENSE", err2) } h.Store.Setting.Set("EDITION-LICENSE", js) - event.Handler().Publish(string(event.TypeSystemLicenseChange)) - ctx.Transaction, err = h.Runtime.Db.Beginx() if err != nil { response.WriteServerError(w, method, err) return } - h.Store.Audit.Record(ctx, audit.EventTypeSystemLicense) ctx.Transaction.Commit() + h.Runtime.Log.Info("License changed") + event.Handler().Publish(string(event.TypeSystemLicenseChange), h.Runtime, h.Store) + + h.Store.Audit.Record(ctx, audit.EventTypeSystemLicense) + response.WriteEmpty(w) } diff --git a/server/server.go b/server/server.go index d3b6ab7a..1a2eee05 100644 --- a/server/server.go +++ b/server/server.go @@ -91,6 +91,12 @@ func Start(rt *env.Runtime, s *domain.Store, ready chan struct{}) { // start server if !rt.Flags.SSLEnabled() { rt.Log.Info("Starting non-SSL server on " + rt.Flags.HTTPPort) + if rt.Flags.SiteMode == env.SiteModeSetup { + rt.Log.Info("***") + rt.Log.Info(fmt.Sprintf("*** Go to http://localhost:%s/setup in your web browser and complete setup wizard ***", rt.Flags.HTTPPort)) + rt.Log.Info("***") + } + n.Run(testHost + ":" + rt.Flags.HTTPPort) } else { if rt.Flags.ForceHTTPPort2SSL != "" { @@ -109,6 +115,12 @@ func Start(rt *env.Runtime, s *domain.Store, ready chan struct{}) { }() } + if rt.Flags.SiteMode == env.SiteModeSetup { + rt.Log.Info("***") + rt.Log.Info(fmt.Sprintf("*** Go to https://localhost:%s/setup in your web browser and complete setup wizard ***", rt.Flags.HTTPPort)) + rt.Log.Info("***") + } + rt.Log.Info("Starting SSL server on " + rt.Flags.HTTPPort + " with " + rt.Flags.SSLCertFile + " " + rt.Flags.SSLKeyFile) // TODO: https://blog.gopheracademy.com/advent-2016/exposing-go-on-the-internet/