Skip to content

Commit 888569d

Browse files
committed
setup mode message & license change callback params
1 parent 4b24cbc commit 888569d

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

domain/setting/endpoint.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,33 +148,37 @@ func (h *Handler) SetLicense(w http.ResponseWriter, r *http.Request) {
148148
lj := licenseJSON{}
149149
x := licenseXML{Key: "", Signature: ""}
150150

151-
err = xml.Unmarshal([]byte(config), &x)
152-
if err == nil {
151+
err1 := xml.Unmarshal([]byte(config), &x)
152+
if err1 == nil {
153153
lj.Key = x.Key
154154
lj.Signature = x.Signature
155155
} else {
156156
h.Runtime.Log.Error("failed to XML unmarshal EDITION-LICENSE", err)
157157
}
158158

159-
j, err := json.Marshal(lj)
159+
j, err2 := json.Marshal(lj)
160160
js := "{}"
161-
if err == nil {
161+
if err2 == nil {
162162
js = string(j)
163+
} else {
164+
h.Runtime.Log.Error("failed to JSON marshal EDITION-LICENSE", err2)
163165
}
164166

165167
h.Store.Setting.Set("EDITION-LICENSE", js)
166168

167-
event.Handler().Publish(string(event.TypeSystemLicenseChange))
168-
169169
ctx.Transaction, err = h.Runtime.Db.Beginx()
170170
if err != nil {
171171
response.WriteServerError(w, method, err)
172172
return
173173
}
174174

175-
h.Store.Audit.Record(ctx, audit.EventTypeSystemLicense)
176175
ctx.Transaction.Commit()
177176

177+
h.Runtime.Log.Info("License changed")
178+
event.Handler().Publish(string(event.TypeSystemLicenseChange), h.Runtime, h.Store)
179+
180+
h.Store.Audit.Record(ctx, audit.EventTypeSystemLicense)
181+
178182
response.WriteEmpty(w)
179183
}
180184

server/server.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ func Start(rt *env.Runtime, s *domain.Store, ready chan struct{}) {
9191
// start server
9292
if !rt.Flags.SSLEnabled() {
9393
rt.Log.Info("Starting non-SSL server on " + rt.Flags.HTTPPort)
94+
if rt.Flags.SiteMode == env.SiteModeSetup {
95+
rt.Log.Info("***")
96+
rt.Log.Info(fmt.Sprintf("*** Go to http://localhost:%s/setup in your web browser and complete setup wizard ***", rt.Flags.HTTPPort))
97+
rt.Log.Info("***")
98+
}
99+
94100
n.Run(testHost + ":" + rt.Flags.HTTPPort)
95101
} else {
96102
if rt.Flags.ForceHTTPPort2SSL != "" {
@@ -109,6 +115,12 @@ func Start(rt *env.Runtime, s *domain.Store, ready chan struct{}) {
109115
}()
110116
}
111117

118+
if rt.Flags.SiteMode == env.SiteModeSetup {
119+
rt.Log.Info("***")
120+
rt.Log.Info(fmt.Sprintf("*** Go to https://localhost:%s/setup in your web browser and complete setup wizard ***", rt.Flags.HTTPPort))
121+
rt.Log.Info("***")
122+
}
123+
112124
rt.Log.Info("Starting SSL server on " + rt.Flags.HTTPPort + " with " + rt.Flags.SSLCertFile + " " + rt.Flags.SSLKeyFile)
113125

114126
// TODO: https://blog.gopheracademy.com/advent-2016/exposing-go-on-the-internet/

0 commit comments

Comments
 (0)