mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 12:42:34 +02:00
v0.5: removed system service env, log output format fix
This commit is contained in:
parent
85fb637551
commit
23e7d06081
4 changed files with 10 additions and 18 deletions
|
@ -7,7 +7,6 @@ import (
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
var IsRunningAsService = getEnvBool("GOPROXY_IS_SYSTEMD")
|
|
||||||
var NoSchemaValidation = getEnvBool("GOPROXY_NO_SCHEMA_VALIDATION")
|
var NoSchemaValidation = getEnvBool("GOPROXY_NO_SCHEMA_VALIDATION")
|
||||||
var IsDebug = getEnvBool("GOPROXY_DEBUG")
|
var IsDebug = getEnvBool("GOPROXY_DEBUG")
|
||||||
|
|
||||||
|
|
19
src/main.go
19
src/main.go
|
@ -32,19 +32,12 @@ func main() {
|
||||||
logrus.SetLevel(logrus.DebugLevel)
|
logrus.SetLevel(logrus.DebugLevel)
|
||||||
}
|
}
|
||||||
|
|
||||||
if common.IsRunningAsService {
|
logrus.SetFormatter(&logrus.TextFormatter{
|
||||||
logrus.SetFormatter(&logrus.TextFormatter{
|
DisableSorting: true,
|
||||||
DisableColors: true,
|
FullTimestamp: true,
|
||||||
DisableTimestamp: true,
|
ForceColors: true,
|
||||||
DisableSorting: true,
|
TimestampFormat: "01-02 15:04:05",
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
logrus.SetFormatter(&logrus.TextFormatter{
|
|
||||||
DisableSorting: true,
|
|
||||||
FullTimestamp: true,
|
|
||||||
TimestampFormat: "01-02 15:04:05",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if args.Command == common.CommandReload {
|
if args.Command == common.CommandReload {
|
||||||
if err := apiUtils.ReloadServer(); err.IsNotNil() {
|
if err := apiUtils.ReloadServer(); err.IsNotNil() {
|
||||||
|
|
|
@ -155,7 +155,7 @@ func (p *Provider) loadRoutes() E.NestedError {
|
||||||
e.Alias = a
|
e.Alias = a
|
||||||
r, err := R.NewRoute(e)
|
r, err := R.NewRoute(e)
|
||||||
if err.IsNotNil() {
|
if err.IsNotNil() {
|
||||||
errors.Addf("%s: %w", a, err)
|
errors.Add(err.Subject(a))
|
||||||
p.l.Debugf("failed to load route: %s, %s", a, err)
|
p.l.Debugf("failed to load route: %s, %s", a, err)
|
||||||
} else {
|
} else {
|
||||||
p.routes.Set(a, r)
|
p.routes.Set(a, r)
|
||||||
|
|
|
@ -67,7 +67,7 @@ func NewHTTPRoute(entry *P.Entry) (*HTTPRoute, E.NestedError) {
|
||||||
path := entry.Path.String()
|
path := entry.Path.String()
|
||||||
if _, exists := r.Subroutes[path]; exists {
|
if _, exists := r.Subroutes[path]; exists {
|
||||||
httpRoutes.Unlock()
|
httpRoutes.Unlock()
|
||||||
return nil, E.Duplicated("path", path).Subject(entry.Alias)
|
return nil, E.Duplicated("path", path)
|
||||||
}
|
}
|
||||||
r.mux.HandleFunc(path, rp.ServeHTTP)
|
r.mux.HandleFunc(path, rp.ServeHTTP)
|
||||||
if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
|
@ -75,9 +75,9 @@ func NewHTTPRoute(entry *P.Entry) (*HTTPRoute, E.NestedError) {
|
||||||
switch t := err.(type) {
|
switch t := err.(type) {
|
||||||
case error:
|
case error:
|
||||||
// NOTE: likely path pattern error
|
// NOTE: likely path pattern error
|
||||||
return nil, E.From(t).Subject(entry.Alias)
|
return nil, E.From(t)
|
||||||
default:
|
default:
|
||||||
return nil, E.From(fmt.Errorf("%v", t)).Subject(entry.Alias)
|
return nil, E.From(fmt.Errorf("%v", t))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue