Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjramsay <jcai@gitlab.com>2019-12-03 20:22:15 +0300
committerJohn Cai <jcai@gitlab.com>2019-12-04 17:37:51 +0300
commitcecb28de16b63e4b807403e429de687adaa2e3b4 (patch)
tree0aa40236ccf45e13f1c20fe7c43bb3c380a34a49 /internal/bootstrap
parent07c5914b25d90c69407358d63c2192b3eb0eabab (diff)
Move bootstrap env vars into bootstrap constructor
Both Gitaly and Praefect use the bootstrap package and need to play well with gitaly-wrapper. This changes praefect to use the same env vars as gitaly. It also moves the env var retrieval inside the bootstrap constructor.
Diffstat (limited to 'internal/bootstrap')
-rw-r--r--internal/bootstrap/bootstrap.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/internal/bootstrap/bootstrap.go b/internal/bootstrap/bootstrap.go
index 41c1c7d89..214487e63 100644
--- a/internal/bootstrap/bootstrap.go
+++ b/internal/bootstrap/bootstrap.go
@@ -13,6 +13,13 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/config"
)
+const (
+ // EnvPidFile is the name of the environment variable containing the pid file path
+ EnvPidFile = "GITALY_PID_FILE"
+ // EnvUpgradesEnabled is an environment variable that when defined gitaly must enable graceful upgrades on SIGHUP
+ EnvUpgradesEnabled = "GITALY_UPGRADES_ENABLED"
+)
+
// Bootstrap handles graceful upgrades
type Bootstrap struct {
// StopAction will be invoked during a graceful stop. It must wait until the shutdown is completed
@@ -54,7 +61,11 @@ type upgrader interface {
// * upg.Exit() channel in p1 will be closed now and p1 can gracefully terminate already accepted connections
// * upgrades cannot starts again if p1 and p2 are both running, an hard termination should be scheduled to overcome
// freezes during a graceful shutdown
-func New(pidFile string, upgradesEnabled bool) (*Bootstrap, error) {
+// gitaly-wrapper is supposed to set EnvUpgradesEnabled in order to enable graceful upgrades
+func New() (*Bootstrap, error) {
+ pidFile := os.Getenv(EnvPidFile)
+ _, upgradesEnabled := os.LookupEnv(EnvUpgradesEnabled)
+
// PIDFile is optional, if provided tableflip will keep it updated
upg, err := tableflip.New(tableflip.Options{PIDFile: pidFile})
if err != nil {