summaryrefslogtreecommitdiff
path: root/go/internal/handler/handler.go
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-05-23 15:41:34 +0000
committerDouwe Maan <douwe@gitlab.com>2017-05-23 15:41:34 +0000
commitdb96f7244f52842798e2fb4261677838d2766162 (patch)
tree900bf1023803d32a3ee67356848e3e3ebad1434f /go/internal/handler/handler.go
parent285c061ed8933c0d94a9ad027f99653039673324 (diff)
parentf3b83553d67058003819fb844c8a1cde1da5c9af (diff)
downloadgitlab-shell-db96f7244f52842798e2fb4261677838d2766162.tar.gz
Merge branch 'go-wrappers' into 'master'
Use gitaly-upload-pack and gitaly-receive-pack Closes gitaly#193 See merge request !129
Diffstat (limited to 'go/internal/handler/handler.go')
-rw-r--r--go/internal/handler/handler.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/go/internal/handler/handler.go b/go/internal/handler/handler.go
new file mode 100644
index 0000000..927998d
--- /dev/null
+++ b/go/internal/handler/handler.go
@@ -0,0 +1,38 @@
+package handler
+
+import (
+ "os"
+ "os/exec"
+ "syscall"
+
+ "gitlab.com/gitlab-org/gitlab-shell/go/internal/config"
+ "gitlab.com/gitlab-org/gitlab-shell/go/internal/logger"
+)
+
+func Prepare() error {
+ cfg, err := config.New()
+ if err != nil {
+ return err
+ }
+
+ if err := logger.Configure(cfg); err != nil {
+ return err
+ }
+
+ // Use a working directory that won't get removed or unmounted.
+ if err := os.Chdir("/"); err != nil {
+ return err
+ }
+
+ return nil
+}
+
+func execCommand(command string, args ...string) error {
+ binPath, err := exec.LookPath(command)
+ if err != nil {
+ return err
+ }
+
+ args = append([]string{binPath}, args...)
+ return syscall.Exec(binPath, args, os.Environ())
+}