mirror of
https://github.com/engineer-man/piston.git
synced 2025-04-23 21:46:27 +02:00
modify repo and docs for lxc only
This commit is contained in:
parent
620107212e
commit
a954759dae
27 changed files with 67 additions and 340 deletions
19
api/main.go
19
api/main.go
|
@ -6,10 +6,8 @@ import (
|
|||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -25,7 +23,6 @@ type problem struct {
|
|||
}
|
||||
|
||||
type outbound struct {
|
||||
Generator string `json:"instance"`
|
||||
Ran bool `json:"ran"`
|
||||
Output string `json:"output"`
|
||||
}
|
||||
|
@ -35,15 +32,6 @@ var instance int
|
|||
func main() {
|
||||
port := 2000
|
||||
|
||||
if len(os.Args) > 1 {
|
||||
if i, err := strconv.Atoi(os.Args[1]); err == nil {
|
||||
instance = i
|
||||
port += i
|
||||
}
|
||||
} else {
|
||||
instance = 0
|
||||
}
|
||||
|
||||
fmt.Println("starting api on port", port)
|
||||
|
||||
http.HandleFunc("/execute", Execute)
|
||||
|
@ -111,13 +99,7 @@ func launch(request inbound, res http.ResponseWriter) {
|
|||
args = append(args, strings.Join(request.Args, "\n"))
|
||||
|
||||
// set up the execution
|
||||
//cmd := exec.Command("../docker/execute", args...)
|
||||
cmd := exec.Command("../lxc/execute", args...)
|
||||
cmd.Env = os.Environ()
|
||||
|
||||
if instance > 0 {
|
||||
cmd.Env = append(cmd.Env, fmt.Sprintf("SOCKET=unix:///var/run/docker-%d.sock", instance))
|
||||
}
|
||||
|
||||
// capture out/err
|
||||
var stdout, stderr bytes.Buffer
|
||||
|
@ -128,7 +110,6 @@ func launch(request inbound, res http.ResponseWriter) {
|
|||
|
||||
// prepare response
|
||||
outbound := outbound{
|
||||
Generator: fmt.Sprintf("docker-%d", instance),
|
||||
Ran: err == nil,
|
||||
Output: strings.TrimSpace(stdout.String()),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue