From 53dc3d8273cf7f2be813821f4e8c7f0f6c8a78b4 Mon Sep 17 00:00:00 2001 From: John Cai Date: Fri, 25 Aug 2023 17:48:13 -0400 Subject: gitaly: Set kill function for killing off processes that stay alive Now that we have a way to kill processes with sigkill after a determined amount of time, let's use it in the main command factory. --- internal/cli/gitaly/serve.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/cli/gitaly/serve.go b/internal/cli/gitaly/serve.go index fd4470241..d90460910 100644 --- a/internal/cli/gitaly/serve.go +++ b/internal/cli/gitaly/serve.go @@ -210,6 +210,15 @@ func run(cfg config.Cfg, logger logrus.FieldLogger) error { commandFactoryOpts = append(commandFactoryOpts, git.WithSkipHooks()) } + commandKillWait := (cfg.GracefulRestartTimeout.Duration() * 3) / 4 + commandFactoryOpts = append( + commandFactoryOpts, + git.WithKillFunc( + time.After(commandKillWait), + helper.NewTimerTicker(commandKillWait/5), + ), + ) + gitCmdFactory, cleanup, err := git.NewExecCommandFactory(cfg, logger, commandFactoryOpts...) if err != nil { return fmt.Errorf("creating Git command factory: %w", err) -- cgit v1.2.3