woj-server/internal/service/runner/deps.go
Paul Pan d42ee0ce54 feat: a big update
1. merge woj-runner scripts into woj-server
2. add woj-runner app
3. refactor submission status problem ...
4. jwt middleware update

Co-authored-by: cxy004 <cxy004@qq.com>
Co-authored-by: wzt <w.zhongtao@qq.com>
2022-10-22 17:38:39 +08:00

32 lines
624 B
Go

package runner
import (
"github.com/WHUPRJ/woj-server/internal/e"
"github.com/WHUPRJ/woj-server/pkg/utils"
"go.uber.org/zap"
"os"
"os/exec"
"path/filepath"
)
func (s *service) EnsureDeps(force bool) e.Status {
mark := filepath.Join(Prefix, ".mark.docker")
if force {
_ = os.Remove(mark)
} else if utils.FileExist(mark) {
return e.Success
}
script := filepath.Join(ScriptsDir, "prepare_container.sh")
cmd := exec.Command(script)
cmd.Dir = ScriptsDir
err := cmd.Run()
if err != nil {
s.log.Warn("prebuild docker images failed", zap.Error(err))
return e.RunnerDepsBuildFailed
}
return e.Success
}