mirror of
https://github.com/yusing/godoxy.git
synced 2025-07-22 20:24:03 +02:00
correcting startup behavior
This commit is contained in:
parent
00fc75b61b
commit
9889b5a8d3
1 changed files with 27 additions and 35 deletions
62
cmd/main.go
62
cmd/main.go
|
@ -26,17 +26,40 @@ import (
|
||||||
func main() {
|
func main() {
|
||||||
args := common.GetArgs()
|
args := common.GetArgs()
|
||||||
|
|
||||||
if args.Command == common.CommandSetup {
|
switch args.Command {
|
||||||
|
case common.CommandSetup:
|
||||||
internal.Setup()
|
internal.Setup()
|
||||||
return
|
return
|
||||||
}
|
case common.CommandReload:
|
||||||
|
|
||||||
if args.Command == common.CommandReload {
|
|
||||||
if err := query.ReloadServer(); err != nil {
|
if err := query.ReloadServer(); err != nil {
|
||||||
E.LogFatal("server reload error", err)
|
E.LogFatal("server reload error", err)
|
||||||
}
|
}
|
||||||
logging.Info().Msg("ok")
|
logging.Info().Msg("ok")
|
||||||
return
|
return
|
||||||
|
case common.CommandListIcons:
|
||||||
|
icons, err := internal.ListAvailableIcons()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
printJSON(icons)
|
||||||
|
return
|
||||||
|
case common.CommandListRoutes:
|
||||||
|
routes, err := query.ListRoutes()
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("failed to connect to api server: %s", err)
|
||||||
|
log.Printf("falling back to config file")
|
||||||
|
printJSON(config.RoutesByAlias())
|
||||||
|
} else {
|
||||||
|
printJSON(routes)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
case common.CommandDebugListMTrace:
|
||||||
|
trace, err := query.ListMiddlewareTraces()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
printJSON(trace)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if args.Command == common.CommandStart {
|
if args.Command == common.CommandStart {
|
||||||
|
@ -75,43 +98,12 @@ func main() {
|
||||||
case common.CommandListConfigs:
|
case common.CommandListConfigs:
|
||||||
printJSON(config.Value())
|
printJSON(config.Value())
|
||||||
return
|
return
|
||||||
case common.CommandListRoutes:
|
|
||||||
routes, err := query.ListRoutes()
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("failed to connect to api server: %s", err)
|
|
||||||
log.Printf("falling back to config file")
|
|
||||||
printJSON(config.RoutesByAlias())
|
|
||||||
} else {
|
|
||||||
printJSON(routes)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
case common.CommandListIcons:
|
|
||||||
icons, err := internal.ListAvailableIcons()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
printJSON(icons)
|
|
||||||
return
|
|
||||||
case common.CommandDebugListEntries:
|
case common.CommandDebugListEntries:
|
||||||
printJSON(config.DumpEntries())
|
printJSON(config.DumpEntries())
|
||||||
return
|
return
|
||||||
case common.CommandDebugListProviders:
|
case common.CommandDebugListProviders:
|
||||||
printJSON(config.DumpProviders())
|
printJSON(config.DumpProviders())
|
||||||
return
|
return
|
||||||
case common.CommandDebugListMTrace:
|
|
||||||
trace, err := query.ListMiddlewareTraces()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
printJSON(trace)
|
|
||||||
return
|
|
||||||
case common.CommandDebugListTasks:
|
|
||||||
tasks, err := query.DebugListTasks()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
printJSON(tasks)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg.StartProxyProviders()
|
cfg.StartProxyProviders()
|
||||||
|
|
Loading…
Add table
Reference in a new issue