feat: read sandbox conf
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
2f8604f647
commit
b608a22cfd
|
@ -10,6 +10,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Conf struct {
|
type Conf struct {
|
||||||
|
SandboxExecServer string `default:"localhost:5051"`
|
||||||
|
SandboxToken string `default:""`
|
||||||
LogLevel int `default:"0"`
|
LogLevel int `default:"0"`
|
||||||
OutputPath string `default:"joj3_result.json"`
|
OutputPath string `default:"joj3_result.json"`
|
||||||
Stages []struct {
|
Stages []struct {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
_ "focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/executors"
|
"focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/executors"
|
||||||
_ "focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/parsers"
|
_ "focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/parsers"
|
||||||
"focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/stage"
|
"focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/stage"
|
||||||
|
|
||||||
|
@ -77,6 +77,7 @@ func main() {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
setupSlog(conf)
|
setupSlog(conf)
|
||||||
|
executors.InitWithConf(conf.SandboxExecServer, conf.SandboxToken)
|
||||||
stages := generateStages(conf)
|
stages := generateStages(conf)
|
||||||
defer stage.Cleanup()
|
defer stage.Cleanup()
|
||||||
results := stage.Run(stages)
|
results := stage.Run(stages)
|
||||||
|
|
|
@ -2,8 +2,13 @@ package executors
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_ "focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/executors/dummy"
|
_ "focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/executors/dummy"
|
||||||
_ "focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/executors/sandbox"
|
"focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/executors/sandbox"
|
||||||
)
|
)
|
||||||
|
|
||||||
// this file does nothing but imports to ensure all the init() functions
|
// this file does nothing but imports to ensure all the init() functions
|
||||||
// in the subpackages are called
|
// in the subpackages are called
|
||||||
|
|
||||||
|
// overwrite the default registered executors
|
||||||
|
func InitWithConf(sandboxExecServer, sandboxToken string) {
|
||||||
|
sandbox.InitWithConf(sandboxExecServer, sandboxToken)
|
||||||
|
}
|
||||||
|
|
|
@ -8,9 +8,17 @@ var name = "sandbox"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
stage.RegisterExecutor(name, &Sandbox{
|
stage.RegisterExecutor(name, &Sandbox{
|
||||||
// TODO: read from conf
|
|
||||||
execServer: "localhost:5051",
|
execServer: "localhost:5051",
|
||||||
token: "",
|
token: "",
|
||||||
cachedMap: make(map[string]string),
|
cachedMap: make(map[string]string),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// overwrite the default registered executor
|
||||||
|
func InitWithConf(execServer, token string) {
|
||||||
|
stage.RegisterExecutor(name, &Sandbox{
|
||||||
|
execServer: execServer,
|
||||||
|
token: token,
|
||||||
|
cachedMap: make(map[string]string),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user