outpost/ldap: add http server for healthchecks
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
4d7dab92bc
commit
7524e114d9
|
@ -30,4 +30,6 @@ FROM gcr.io/distroless/base-debian10:debug
|
||||||
|
|
||||||
COPY --from=builder /go/ldap /
|
COPY --from=builder /go/ldap /
|
||||||
|
|
||||||
|
HEALTHCHECK CMD [ "wget", "--spider", "http://localhost:4180/akprox/ping" ]
|
||||||
|
|
||||||
ENTRYPOINT ["/ldap"]
|
ENTRYPOINT ["/ldap"]
|
||||||
|
|
|
@ -42,14 +42,40 @@ func (ls *LDAPServer) Refresh() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ls *LDAPServer) Start() error {
|
func (ls *LDAPServer) StartHTTPServer() error {
|
||||||
listen := "0.0.0.0:3389"
|
listen := "0.0.0.0:4180" // same port as proxy
|
||||||
log.Debugf("Listening on %s", listen)
|
m := http.NewServeMux()
|
||||||
err := ls.s.ListenAndServe(listen)
|
m.HandleFunc("/akprox/ping", func(rw http.ResponseWriter, r *http.Request) {
|
||||||
if err != nil {
|
rw.WriteHeader(204)
|
||||||
ls.log.Errorf("LDAP Server Failed: %s", err.Error())
|
})
|
||||||
return err
|
ls.log.WithField("listen", listen).Info("Starting http server")
|
||||||
|
return http.ListenAndServe(listen, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ls *LDAPServer) StartLDAPServer() error {
|
||||||
|
listen := "0.0.0.0:3389"
|
||||||
|
ls.log.WithField("listen", listen).Info("Starting ldap server")
|
||||||
|
return ls.s.ListenAndServe(listen)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ls *LDAPServer) Start() error {
|
||||||
|
wg := sync.WaitGroup{}
|
||||||
|
wg.Add(2)
|
||||||
|
go func() {
|
||||||
|
defer wg.Done()
|
||||||
|
err := ls.StartHTTPServer()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
go func() {
|
||||||
|
defer wg.Done()
|
||||||
|
err := ls.StartLDAPServer()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
wg.Wait()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue