diff options
author | John Cai <jcai@gitlab.com> | 2019-11-20 02:23:12 +0300 |
---|---|---|
committer | jramsay <jcai@gitlab.com> | 2019-11-27 05:06:32 +0300 |
commit | 98c8ee4518ddd8d0d377915edc946e6d5010d658 (patch) | |
tree | 9932a0826248ab5ea1210e0c242b9bc1bf7fec15 /internal/rubyserver | |
parent | 1332007de9a21540582ed752dd664382369eaca9 (diff) |
Generalize internal gitaly socket dir
Both gitaly-ruby and gitaly hooks will need the gitaly internal socket
directory, so we can pull it out into the config package. Also this
change starts an internal gitaly socket that listens for connections.
Diffstat (limited to 'internal/rubyserver')
-rw-r--r-- | internal/rubyserver/rubyserver.go | 34 |
1 files changed, 2 insertions, 32 deletions
diff --git a/internal/rubyserver/rubyserver.go b/internal/rubyserver/rubyserver.go index 5f55e3ff4..c95b6934d 100644 --- a/internal/rubyserver/rubyserver.go +++ b/internal/rubyserver/rubyserver.go @@ -3,7 +3,6 @@ package rubyserver import ( "context" "fmt" - "io/ioutil" "net" "os" "path" @@ -14,7 +13,6 @@ import ( grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware" grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus" - log "github.com/sirupsen/logrus" "gitlab.com/gitlab-org/gitaly/internal/command" "gitlab.com/gitlab-org/gitaly/internal/config" "gitlab.com/gitlab-org/gitaly/internal/git/hooks" @@ -31,10 +29,6 @@ import ( ) var ( - socketDir string - - lazyInit sync.Once - // ConnectTimeout is the timeout for establishing a connection to the gitaly-ruby process. ConnectTimeout = 40 * time.Second ) @@ -46,27 +40,10 @@ func init() { } } -func prepareSocketPath() { - if config.Config.InternalSocketDir != "" { - socketDir = config.Config.InternalSocketDir - return - } - - // The socket path must be short-ish because listen(2) fails on long - // socket paths. We hope/expect that ioutil.TempDir creates a directory - // that is not too deep. We need a directory, not a tempfile, because we - // will later want to set its permissions to 0700. The permission change - // is done in the Ruby child process. - var err error - socketDir, err = ioutil.TempDir("", "gitaly-ruby") - if err != nil { - log.Fatalf("create ruby server socket directory: %v", err) - } -} - func socketPath(id int) string { + socketDir := config.InternalSocketDir() if socketDir == "" { - panic("socketDir is not set") + panic("internal socket directory is missing") } return filepath.Join(socketDir, fmt.Sprintf("ruby.%d", id)) @@ -95,11 +72,6 @@ func (s *Server) Stop() { w.Process.Stop() } } - - // If we use the old gitaly-ruby temp dir, we should clean up - if config.Config.InternalSocketDir == "" && socketDir != "" { - os.RemoveAll(socketDir) - } } // Start spawns the Ruby server. @@ -109,8 +81,6 @@ func (s *Server) Start() error { } func (s *Server) start() error { - lazyInit.Do(prepareSocketPath) - wd, err := os.Getwd() if err != nil { return err |