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:
authorJacob Vosmaer (GitLab) <jacob@gitlab.com>2017-07-27 11:35:43 +0300
committerAndrew Newdigate <andrew@gitlab.com>2017-07-27 11:35:43 +0300
commit0c32842c37e5f41a1d427312f390963237ab57fa (patch)
tree43d6521277989e53ce3da795f241712b1a895c82 /internal/supervisor
parent0ffed4e45f9ced7aec0d15187432d85d68295f7d (diff)
Implement CommitService.CommitLanguages
Diffstat (limited to 'internal/supervisor')
-rw-r--r--internal/supervisor/supervisor.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/internal/supervisor/supervisor.go b/internal/supervisor/supervisor.go
new file mode 100644
index 000000000..4f9bba63e
--- /dev/null
+++ b/internal/supervisor/supervisor.go
@@ -0,0 +1,39 @@
+package supervisor
+
+import (
+ "fmt"
+ "os"
+ "os/exec"
+)
+
+// Process represents a running process.
+type Process struct {
+ cmd *exec.Cmd
+}
+
+// New creates a new proces instance.
+func New(env []string, args []string, dir string) (*Process, error) {
+ if len(args) < 1 {
+ return nil, fmt.Errorf("need at least one argument")
+ }
+
+ cmd := exec.Command(args[0], args[1:]...)
+ cmd.Env = env
+ cmd.Dir = dir
+ cmd.Stdout = os.Stdout
+ cmd.Stderr = os.Stderr
+
+ // TODO: spawn goroutine that watches (restarts) this process.
+ return &Process{cmd: cmd}, cmd.Start()
+}
+
+// Stop terminates the process.
+func (p *Process) Stop() {
+ if p == nil || p.cmd == nil || p.cmd.Process == nil {
+ return
+ }
+
+ process := p.cmd.Process
+ process.Kill()
+ process.Wait()
+}