1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2025-08-06 10:25:22 +02:00

Graceful: Allow graceful restart for fcgi (#9112)

* Graceful: Allow graceful restart for fcgi

My previous interpretation was incorrect - we do not handle sockets
being passed in over stdin

* Update web.go
This commit is contained in:
zeripath 2019-11-24 10:39:50 +00:00 committed by GitHub
parent d779deef6e
commit 7523314ef8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 16 deletions

View file

@ -6,9 +6,12 @@ package cmd
import (
"crypto/tls"
"net"
"net/http"
"net/http/fcgi"
"code.gitea.io/gitea/modules/graceful"
"code.gitea.io/gitea/modules/log"
)
func runHTTP(network, listenAddr string, m http.Handler) error {
@ -33,3 +36,17 @@ func NoHTTPRedirector() {
func NoMainListener() {
graceful.Manager.InformCleanup()
}
func runFCGI(listenAddr string, m http.Handler) error {
// This needs to handle stdin as fcgi point
fcgiServer := graceful.NewServer("tcp", listenAddr)
err := fcgiServer.ListenAndServe(func(listener net.Listener) error {
return fcgi.Serve(listener, m)
})
if err != nil {
log.Fatal("Failed to start FCGI main server: %v", err)
}
log.Info("FCGI Listener: %s Closed", listenAddr)
return err
}