Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ func main() {
elastic2.InitTemplate(false)

if global.Env().SetupRequired() {
for _, v := range modules {
for k, v := range modules {
log.Debugf("start module: %v", k)
v.Value.Start()
}
}
Expand Down
3 changes: 0 additions & 3 deletions modules/security/realm/authc/native/permission.json
Original file line number Diff line number Diff line change
Expand Up @@ -591,9 +591,6 @@
{"name": "template.get", "methods": ["get"],
"path": "/_template/:template_name"
},
{"name": "template.exists", "methods": ["head"],
"path": "/_template/:template_name"
},
{"name": "template.put", "methods": ["put", "post"],
"path": "/_template/:template_name"
},
Expand Down
99 changes: 53 additions & 46 deletions plugin/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,28 +195,30 @@ func (module *Module) validate(w http.ResponseWriter, r *http.Request, ps httpro
result := util.MapStr{}
result["success"] = success

if r := recover(); r != nil {
var v string
switch r.(type) {
case error:
v = r.(error).Error()
case runtime.Error:
v = r.(runtime.Error).Error()
case string:
v = r.(string)
}
if v != "" {
success = false
result["error"] = util.MapStr{
"reason": v,
}
if errType != "" {
result["type"] = errType
if !global.Env().IsDebug {
if r := recover(); r != nil {
var v string
switch r.(type) {
case error:
v = r.(error).Error()
case runtime.Error:
v = r.(runtime.Error).Error()
case string:
v = r.(string)
}
if fixTips != "" {
result["fix_tips"] = fixTips
if v != "" {
success = false
result["error"] = util.MapStr{
"reason": v,
}
if errType != "" {
result["type"] = errType
}
if fixTips != "" {
result["fix_tips"] = fixTips
}
code = http.StatusInternalServerError
}
code = http.StatusInternalServerError
}
}
module.WriteJSON(w, result, code)
Expand Down Expand Up @@ -427,31 +429,33 @@ func (module *Module) initialize(w http.ResponseWriter, r *http.Request, ps http
"secret_mismatch": secretMismatch,
}
result["success"] = success

if r := recover(); r != nil {
var v string
switch r.(type) {
case error:
v = r.(error).Error()
case runtime.Error:
v = r.(runtime.Error).Error()
case string:
v = r.(string)
}
if v != "" {
success = false
result["error"] = util.MapStr{
"reason": v,
if !global.Env().IsDebug {
if r := recover(); r != nil {
var v string
switch r.(type) {
case error:
v = r.(error).Error()
case runtime.Error:
v = r.(runtime.Error).Error()
case string:
v = r.(string)
}
if errType != "" {
result["type"] = errType
if v != "" {
success = false
result["error"] = util.MapStr{
"reason": v,
}
if errType != "" {
result["type"] = errType
}
if fixTips != "" {
result["fix_tips"] = fixTips
}
code = http.StatusInternalServerError
}
if fixTips != "" {
result["fix_tips"] = fixTips
}
code = http.StatusInternalServerError
}
}

module.WriteJSON(w, result, code)
}()
err, client := module.initTempClient(request)
Expand Down Expand Up @@ -793,12 +797,15 @@ func (module *Module) initializeTemplate(w http.ResponseWriter, r *http.Request,

// recover from panic and return error message
defer func() {
if v := recover(); v != nil {
module.WriteJSON(w, util.MapStr{
"success": false,
"log": fmt.Sprintf("%v", v),
}, http.StatusOK)
if !global.Env().IsDebug {
if v := recover(); v != nil {
module.WriteJSON(w, util.MapStr{
"success": false,
"log": fmt.Sprintf("%v", v),
}, http.StatusOK)
}
}

}()

request := &SetupRequest{}
Expand Down
8 changes: 5 additions & 3 deletions service/alerting/elasticsearch/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -1243,9 +1243,11 @@ func performChannels(channels []alerting.Channel, ctx map[string]interface{}, ra
func (engine *Engine) GenerateTask(rule alerting.Rule) func(ctx context.Context) {
return func(ctx context.Context) {
defer func() {
if err := recover(); err != nil {
log.Error(err)
debug.PrintStack()
if !global.Env().IsDebug {
if err := recover(); err != nil {
log.Error(err)
debug.PrintStack()
}
}
}()
err := engine.Do(&rule)
Expand Down
Loading