forked from ga4gh/task-execution-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing the docker return character issues (by moving from native vers…
…ion to the command line based command runner)
- Loading branch information
Showing
11 changed files
with
68 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package tes_taskengine_worker | ||
|
||
import ( | ||
"log" | ||
"os" | ||
"os/exec" | ||
"strings" | ||
"syscall" | ||
) | ||
|
||
func NewDockerEngine() *DockerCmd { | ||
return &DockerCmd{} | ||
} | ||
|
||
type DockerCmd struct { | ||
} | ||
|
||
func (self DockerCmd) Run(containerName string, args []string, | ||
binds []string, workdir string, remove bool, stdout *os.File, stderr *os.File) (int, error) { | ||
|
||
log.Printf("Docker Binds: %s", binds) | ||
|
||
docker_args := []string{"run", "--rm", "-i", "-w", workdir} | ||
|
||
for _, i := range binds { | ||
docker_args = append(docker_args, "-v", i) | ||
} | ||
docker_args = append(docker_args, containerName) | ||
docker_args = append(docker_args, args...) | ||
log.Printf("Runner docker %s", strings.Join(args, " ")) | ||
|
||
cmd := exec.Command("docker", docker_args...) | ||
|
||
if stdout != nil { | ||
cmd.Stdout = stdout | ||
} | ||
if stderr != nil { | ||
cmd.Stderr = stderr | ||
} | ||
cmd_err := cmd.Run() | ||
exitStatus := 0 | ||
if exiterr, ok := cmd_err.(*exec.ExitError); ok { | ||
if status, ok := exiterr.Sys().(syscall.WaitStatus); ok { | ||
exitStatus = status.ExitStatus() | ||
log.Printf("Exit Status: %d", exitStatus) | ||
} | ||
} else { | ||
log.Printf("cmd.Run: %v", cmd_err) | ||
} | ||
|
||
return exitStatus, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters