File better_socket_path.patch of Package gitaly
Index: gitaly/ruby/bin/gitaly-ruby
===================================================================
--- gitaly.orig/ruby/bin/gitaly-ruby
+++ gitaly/ruby/bin/gitaly-ruby
@@ -31,9 +31,9 @@ def main
abort "invalid PPID: #{ppid.inspect}" unless ppid_i > 0
FileUtils.rm_f(socket_path)
- socket_dir = File.dirname(socket_path)
- FileUtils.mkdir_p(socket_dir)
- File.chmod(0700, socket_dir)
+ # socket_dir = File.dirname(socket_path)
+ # FileUtils.mkdir_p(socket_dir)
+ # File.chmod(0700, socket_dir)
Labkit::FIPS.enable_fips_mode! if Labkit::FIPS.enabled?
Index: gitaly/internal/gitaly/config/config.go
===================================================================
--- gitaly.orig/internal/gitaly/config/config.go
+++ gitaly/internal/gitaly/config/config.go
@@ -467,7 +467,7 @@ func (cfg *Cfg) Storage(storageName stri
// InternalSocketDir returns the location of the internal socket directory.
func (cfg *Cfg) InternalSocketDir() string {
- return filepath.Join(cfg.RuntimeDir, "sock.d")
+ return "/srv/www/vhosts/gitlab-ce/tmp/sockets/private/internal/"
}
// InternalSocketPath is the path to the internal Gitaly socket.
@@ -632,11 +632,12 @@ func SetupRuntimeDirectory(cfg Cfg, proc
// as the runtime directory. This may not always be an ideal choice given that
// it's typically created at `/tmp`, which may get periodically pruned if `noatime`
// is set.
- var err error
- runtimeDir, err = os.MkdirTemp("", "gitaly-")
- if err != nil {
- return "", fmt.Errorf("creating temporary runtime directory: %w", err)
- }
+ // var err error
+ // runtimeDir, err = os.MkdirTemp("", "gitaly-")
+ // if err != nil {
+ // return "", fmt.Errorf("creating temporary runtime directory: %w", err)
+ // }
+ runtimeDir = "/var/lib/gitaly/"
} else {
// Otherwise, we use the configured runtime directory. Note that we don't use the
// runtime directory directly, but instead create a subdirectory within it which is
@@ -673,8 +674,10 @@ func SetupRuntimeDirectory(cfg Cfg, proc
// socket paths. We hope/expect that os.MkdirTemp 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
- if err := os.Mkdir(cfg.InternalSocketDir(), 0750); err != nil {
- return "", fmt.Errorf("create internal socket directory: %w", err)
+ if err := validateIsDirectory(cfg.InternalSocketDir(), "internal-socket-dir"); err != nil {
+ if err := os.Mkdir(cfg.InternalSocketDir(), 0750); err != nil {
+ return "", fmt.Errorf("create internal socket directory: %w", err)
+ }
}
if err := trySocketCreation(cfg.InternalSocketDir()); err != nil {