outposts: remove duplicate startup/setup code, add pyroscope, make sentry not reconfigure every time (#14724)
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
51
internal/outpost/ak/entrypoint/entrypoint.go
Normal file
51
internal/outpost/ak/entrypoint/entrypoint.go
Normal file
@ -0,0 +1,51 @@
|
||||
package entrypoint
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
"os"
|
||||
|
||||
"goauthentik.io/internal/common"
|
||||
"goauthentik.io/internal/config"
|
||||
"goauthentik.io/internal/debug"
|
||||
"goauthentik.io/internal/outpost/ak"
|
||||
)
|
||||
|
||||
func OutpostMain(appName string, server func(ac *ak.APIController) ak.Outpost) error {
|
||||
debug.EnableDebugServer(appName)
|
||||
akURL := config.Get().AuthentikHost
|
||||
if akURL == "" {
|
||||
return errors.New("environment variable `AUTHENTIK_HOST` not set")
|
||||
}
|
||||
akToken := config.Get().AuthentikToken
|
||||
if akToken == "" {
|
||||
return errors.New("environment variable `AUTHENTIK_TOKEN` not set")
|
||||
}
|
||||
|
||||
akURLActual, err := url.Parse(akURL)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ex := common.Init()
|
||||
defer common.Defer()
|
||||
|
||||
ac := ak.NewAPIController(*akURLActual, akToken)
|
||||
if ac == nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
defer ac.Shutdown()
|
||||
|
||||
ac.Server = server(ac)
|
||||
|
||||
err = ac.Start()
|
||||
if err != nil {
|
||||
ac.Log().WithError(err).Panic("Failed to run server")
|
||||
return err
|
||||
}
|
||||
|
||||
for {
|
||||
<-ex
|
||||
return nil
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user