diff options
author | zeripath <art27@cantab.net> | 2019-11-24 10:39:50 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-24 10:39:50 +0000 |
commit | 7523314ef8564e2c016168d4628f3ab11e27d7ba (patch) | |
tree | 2e7036e99baf567f5e844038796b421983cab5af /cmd/web_graceful.go | |
parent | d779deef6ec95db35299096cc1170ada553b102c (diff) | |
download | gitea-7523314ef8564e2c016168d4628f3ab11e27d7ba.tar.gz gitea-7523314ef8564e2c016168d4628f3ab11e27d7ba.zip |
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
Diffstat (limited to 'cmd/web_graceful.go')
-rw-r--r-- | cmd/web_graceful.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/cmd/web_graceful.go b/cmd/web_graceful.go index 3907e843a2..e303f71510 100644 --- a/cmd/web_graceful.go +++ b/cmd/web_graceful.go @@ -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 +} |