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:4180" // same port as proxy
|
||||||
|
m := http.NewServeMux()
|
||||||
|
m.HandleFunc("/akprox/ping", func(rw http.ResponseWriter, r *http.Request) {
|
||||||
|
rw.WriteHeader(204)
|
||||||
|
})
|
||||||
|
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"
|
listen := "0.0.0.0:3389"
|
||||||
log.Debugf("Listening on %s", listen)
|
ls.log.WithField("listen", listen).Info("Starting ldap server")
|
||||||
err := ls.s.ListenAndServe(listen)
|
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 {
|
if err != nil {
|
||||||
ls.log.Errorf("LDAP Server Failed: %s", err.Error())
|
panic(err)
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
}()
|
||||||
|
go func() {
|
||||||
|
defer wg.Done()
|
||||||
|
err := ls.StartLDAPServer()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
wg.Wait()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue