2021-05-02 23:49:16 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-05-04 13:28:48 +01:00
|
|
|
"fmt"
|
2021-05-02 23:49:16 +01:00
|
|
|
"sync"
|
2021-05-04 13:28:48 +01:00
|
|
|
"time"
|
2021-05-02 23:49:16 +01:00
|
|
|
|
2021-05-04 13:28:48 +01:00
|
|
|
"github.com/getsentry/sentry-go"
|
2021-05-02 23:49:16 +01:00
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
"goauthentik.io/internal/config"
|
2021-05-04 13:28:48 +01:00
|
|
|
"goauthentik.io/internal/constants"
|
2021-05-02 23:49:16 +01:00
|
|
|
"goauthentik.io/internal/gounicorn"
|
|
|
|
"goauthentik.io/internal/web"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2021-05-04 13:07:12 +01:00
|
|
|
log.SetLevel(log.DebugLevel)
|
2021-05-02 23:49:16 +01:00
|
|
|
config.DefaultConfig()
|
2021-05-04 13:07:12 +01:00
|
|
|
config.LoadConfig("./authentik/lib/default.yml")
|
|
|
|
config.LoadConfig("./local.env.yml")
|
2021-05-02 23:49:16 +01:00
|
|
|
config.ConfigureLogger()
|
|
|
|
|
2021-05-04 13:28:48 +01:00
|
|
|
if config.G.ErrorReporting.Enabled {
|
|
|
|
sentry.Init(sentry.ClientOptions{
|
|
|
|
Dsn: "https://a579bb09306d4f8b8d8847c052d3a1d3@sentry.beryju.org/8",
|
|
|
|
AttachStacktrace: true,
|
|
|
|
TracesSampleRate: 0.6,
|
|
|
|
Release: fmt.Sprintf("authentik@%s", constants.VERSION),
|
|
|
|
Environment: config.G.ErrorReporting.Environment,
|
|
|
|
})
|
|
|
|
defer sentry.Flush(time.Second * 5)
|
|
|
|
defer sentry.Recover()
|
|
|
|
}
|
|
|
|
|
2021-05-02 23:49:16 +01:00
|
|
|
rl := log.WithField("logger", "authentik.g")
|
|
|
|
wg := sync.WaitGroup{}
|
|
|
|
wg.Add(2)
|
|
|
|
go func() {
|
|
|
|
defer wg.Done()
|
|
|
|
g := gounicorn.NewGoUnicorn()
|
|
|
|
for {
|
|
|
|
err := g.Start()
|
|
|
|
rl.WithError(err).Warning("gunicorn process died, restarting")
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
go func() {
|
|
|
|
defer wg.Done()
|
|
|
|
ws := web.NewWebServer()
|
|
|
|
ws.Run()
|
|
|
|
}()
|
|
|
|
wg.Wait()
|
|
|
|
}
|