keel/examples/services/main.go
Kevin Franklin Kim 07f0c394d5
feat: add GoRoutine service
moves all services into the service package
2023-09-08 12:17:23 +02:00

39 lines
1.3 KiB
Go

package main
import (
"os"
"github.com/foomo/keel"
)
func main() {
// you can override the below config by settings env vars
_ = os.Setenv("SERVICE_ZAP_ENABLED", "true")
_ = os.Setenv("SERVICE_VIPER_ENABLED", "true")
_ = os.Setenv("SERVICE_PPROF_ENABLED", "true")
_ = os.Setenv("SERVICE_PROMETHEUS_ENABLED", "true")
svr := keel.NewServer(
// add zap service listening on localhost:9100
// allows you to view / change the log level: GET / PUT localhost:9100/log
keel.WithHTTPZapService(false),
// add viper service listening on localhost:9300
// allows you to view / change the configuration: GET / PUT localhost:9300/config
keel.WithHTTPViperService(false),
// add prometheus service listening on 0.0.0.0:9200
// allows you to collect prometheus metrics: GET 0.0.0.0:9200/metrics
keel.WithHTTPPrometheusService(false),
// add go pprof service listening on 0.0.0.0:6060
// allows you to use go tool pprof: GET 0.0.0.0:6060/debug/pprof
keel.WithHTTPPProfService(false),
)
// alternatively you can add them manually
// svr.AddServices(keel.NewDefaultServiceHTTPZap())
// svr.AddServices(keel.NewDefaultServiceHTTPViper())
// svr.AddServices(keel.NewDefaultServiceHTTPPProf())
// svr.AddServices(keel.NewDefaultServiceHTTPPrometheus())
svr.Run()
}