Compare commits
No commits in common. "db0c4f1af0a86ed4f108281c5d2720367fcd1468" and "2f27ecda4528fab8aa67375e6df89cbc25599c96" have entirely different histories.
db0c4f1af0
...
2f27ecda45
4 changed files with 6 additions and 18 deletions
5
cli.go
5
cli.go
|
@ -8,15 +8,12 @@ import (
|
|||
|
||||
"gitea.nulo.in/Nulo/repro-run/runner"
|
||||
"github.com/joho/godotenv"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
func main() {
|
||||
config, err := readConfig()
|
||||
must(err)
|
||||
|
||||
dontDeleteTemp := slices.Contains(os.Args, "--dont-delete-temp")
|
||||
|
||||
env, err := godotenv.Read()
|
||||
if err != nil {
|
||||
log.Printf("Couldn't load env file: %v", err)
|
||||
|
@ -25,7 +22,7 @@ func main() {
|
|||
env[k] = strings.ReplaceAll(v, "\\n", "\n")
|
||||
}
|
||||
|
||||
must(runner.Run(config, "rootfs/", "cache/", ".", nil, dontDeleteTemp, env))
|
||||
must(runner.Run(config, "rootfs/", "cache/", ".", nil, false, env))
|
||||
}
|
||||
|
||||
func must(err error, where ...string) {
|
||||
|
|
|
@ -27,7 +27,7 @@ func (l logWebsocket) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
defer c.Close(websocket.StatusInternalError, "the sky is falling")
|
||||
|
||||
ch := make(chan *[]byte, 1000)
|
||||
ch := make(chan *[]byte)
|
||||
err = run.addWriter(conn{ch: ch})
|
||||
if err != nil {
|
||||
log.Println("addWriter", err)
|
||||
|
@ -38,10 +38,7 @@ func (l logWebsocket) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
if payload == nil {
|
||||
break
|
||||
} else {
|
||||
err = c.Write(context.Background(), websocket.MessageBinary, *payload)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
c.Write(context.Background(), websocket.MessageBinary, *payload)
|
||||
}
|
||||
}
|
||||
c.Close(websocket.StatusNormalClosure, "")
|
||||
|
|
|
@ -23,12 +23,12 @@ import (
|
|||
|
||||
type run struct {
|
||||
mutex sync.Mutex
|
||||
finished bool
|
||||
previous []byte
|
||||
writers []io.WriteCloser
|
||||
}
|
||||
|
||||
func (r *run) Write(p []byte) (n int, err error) {
|
||||
log.Println(string(p))
|
||||
r.mutex.Lock()
|
||||
defer r.mutex.Unlock()
|
||||
r.previous = append(r.previous, p...)
|
||||
|
@ -45,18 +45,13 @@ func (r *run) addWriter(w io.WriteCloser) (err error) {
|
|||
r.mutex.Lock()
|
||||
defer r.mutex.Unlock()
|
||||
|
||||
w.Write(slices.Clone(r.previous))
|
||||
if r.finished {
|
||||
w.Close()
|
||||
} else {
|
||||
r.writers = append(r.writers, w)
|
||||
}
|
||||
go w.Write(slices.Clone(r.previous))
|
||||
r.writers = append(r.writers, w)
|
||||
return
|
||||
}
|
||||
func (r *run) finishRun() {
|
||||
r.mutex.Lock()
|
||||
defer r.mutex.Unlock()
|
||||
r.finished = true
|
||||
for _, c := range r.writers {
|
||||
c.Close()
|
||||
}
|
||||
|
|
|
@ -85,7 +85,6 @@ https://dl-cdn.alpinelinux.org/alpine/v3.17/community`), 0600); err != nil {
|
|||
[]string{"--bind", rootfs, "/",
|
||||
"--ro-bind", src, "/src",
|
||||
"--dev-bind", "/dev", "/dev",
|
||||
"--dev-bind", "/proc", "/proc",
|
||||
"--bind", tmp, "/work",
|
||||
"--unshare-user", "--uid", "1000", "--gid", "1000",
|
||||
"--setenv", "HOME", "/home/repro",
|
||||
|
|
Loading…
Reference in a new issue