Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-workhorse
Commits
8b14e2e8
Commit
8b14e2e8
authored
Jul 29, 2015
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Run git-xxx-pack in its own process group
parent
bfac1947
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
main.go
main.go
+9
-5
No files found.
main.go
View file @
8b14e2e8
...
...
@@ -25,6 +25,7 @@ import (
"path"
"regexp"
"strings"
"syscall"
)
type
gitService
struct
{
...
...
@@ -176,8 +177,7 @@ func handleGetInfoRefs(env gitEnv, _ string, path string, w http.ResponseWriter,
}
// Prepare our Git subprocess
cmd
:=
exec
.
Command
(
"git"
,
subCommand
(
rpc
),
"--stateless-rpc"
,
"--advertise-refs"
,
path
)
setCmdEnv
(
cmd
,
env
)
cmd
:=
gitCommand
(
env
,
"git"
,
subCommand
(
rpc
),
"--stateless-rpc"
,
"--advertise-refs"
,
path
)
stdout
,
err
:=
cmd
.
StdoutPipe
()
if
err
!=
nil
{
fail500
(
w
,
err
)
...
...
@@ -212,11 +212,16 @@ func subCommand(rpc string) string {
return
strings
.
TrimPrefix
(
rpc
,
"git-"
)
}
func
setCmdEnv
(
cmd
*
exec
.
Cmd
,
env
gitEnv
)
{
func
gitCommand
(
env
gitEnv
,
name
string
,
args
...
string
)
*
exec
.
Cmd
{
cmd
:=
exec
.
Command
(
name
,
args
...
)
// Start the command in its own process group (nice for signalling)
cmd
.
SysProcAttr
=
&
syscall
.
SysProcAttr
{
Setpgid
:
true
}
// Explicitly set the environment for the Git command
cmd
.
Env
=
[]
string
{
fmt
.
Sprintf
(
"PATH=%s"
,
os
.
Getenv
(
"PATH"
)),
fmt
.
Sprintf
(
"GL_ID=%s"
,
env
.
GL_ID
),
}
return
cmd
}
func
handlePostRPC
(
env
gitEnv
,
rpc
string
,
path
string
,
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
...
...
@@ -235,8 +240,7 @@ func handlePostRPC(env gitEnv, rpc string, path string, w http.ResponseWriter, r
}
// Prepare our Git subprocess
cmd
:=
exec
.
Command
(
"git"
,
subCommand
(
rpc
),
"--stateless-rpc"
,
path
)
setCmdEnv
(
cmd
,
env
)
cmd
:=
gitCommand
(
env
,
"git"
,
subCommand
(
rpc
),
"--stateless-rpc"
,
path
)
stdout
,
err
:=
cmd
.
StdoutPipe
()
if
err
!=
nil
{
fail500
(
w
,
err
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment