|
@@ -1189,6 +1189,7 @@ func changeGroup(addr string, nameOrGid string) error {
|
|
// ListenAndServe sets up the required http.Server and gets it listening for
|
|
// ListenAndServe sets up the required http.Server and gets it listening for
|
|
// each addr passed in and does protocol specific checking.
|
|
// each addr passed in and does protocol specific checking.
|
|
func ListenAndServe(proto, addr string, job *engine.Job) error {
|
|
func ListenAndServe(proto, addr string, job *engine.Job) error {
|
|
|
|
+ var l net.Listener
|
|
r, err := createRouter(job.Eng, job.GetenvBool("Logging"), job.GetenvBool("EnableCors"), job.Getenv("Version"))
|
|
r, err := createRouter(job.Eng, job.GetenvBool("Logging"), job.GetenvBool("EnableCors"), job.Getenv("Version"))
|
|
if err != nil {
|
|
if err != nil {
|
|
return err
|
|
return err
|
|
@@ -1204,7 +1205,11 @@ func ListenAndServe(proto, addr string, job *engine.Job) error {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- l, err := listenbuffer.NewListenBuffer(proto, addr, activationLock)
|
|
|
|
|
|
+ if job.GetenvBool("BufferRequests") {
|
|
|
|
+ l, err = listenbuffer.NewListenBuffer(proto, addr, activationLock)
|
|
|
|
+ } else {
|
|
|
|
+ l, err = net.Listen(proto, addr)
|
|
|
|
+ }
|
|
if err != nil {
|
|
if err != nil {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
@@ -1276,10 +1281,6 @@ func ServeApi(job *engine.Job) engine.Status {
|
|
)
|
|
)
|
|
activationLock = make(chan struct{})
|
|
activationLock = make(chan struct{})
|
|
|
|
|
|
- if err := job.Eng.Register("acceptconnections", AcceptConnections); err != nil {
|
|
|
|
- return job.Error(err)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
for _, protoAddr := range protoAddrs {
|
|
for _, protoAddr := range protoAddrs {
|
|
protoAddrParts := strings.SplitN(protoAddr, "://", 2)
|
|
protoAddrParts := strings.SplitN(protoAddr, "://", 2)
|
|
if len(protoAddrParts) != 2 {
|
|
if len(protoAddrParts) != 2 {
|
|
@@ -1306,7 +1307,9 @@ func AcceptConnections(job *engine.Job) engine.Status {
|
|
go systemd.SdNotify("READY=1")
|
|
go systemd.SdNotify("READY=1")
|
|
|
|
|
|
// close the lock so the listeners start accepting connections
|
|
// close the lock so the listeners start accepting connections
|
|
- close(activationLock)
|
|
|
|
|
|
+ if activationLock != nil {
|
|
|
|
+ close(activationLock)
|
|
|
|
+ }
|
|
|
|
|
|
return engine.StatusOK
|
|
return engine.StatusOK
|
|
}
|
|
}
|