diff --git a/.vscode/launch.json b/.vscode/launch.json index f3430c86..d35bbe92 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -44,8 +44,10 @@ "0", "--role", "worker", - "--runtime", + "--runtime-path", "/tmp/runtime", + "--runtime-cli", + "bls-runtime", "--workspace", "/tmp/debug/worker", "--private-key", diff --git a/executor/command.go b/executor/command.go index 01d5eee8..39d7359e 100644 --- a/executor/command.go +++ b/executor/command.go @@ -20,6 +20,7 @@ func (e *Executor) createCmd(paths requestPaths, req execute.Request) *exec.Cmd cfg := req.Config.Runtime cfg.Input = paths.input cfg.FSRoot = paths.fsRoot + cfg.DriversRootPath = e.cfg.DriversRootPath // Prepare CLI arguments. // Append the input argument first first. diff --git a/executor/config.go b/executor/config.go index fb1d659f..16e723f2 100644 --- a/executor/config.go +++ b/executor/config.go @@ -13,6 +13,7 @@ var defaultConfig = Config{ ExecutableName: blockless.RuntimeCLI(), FS: afero.NewOsFs(), Limiter: &noopLimiter{}, + DriversRootPath: "", } // Config represents the Executor configuration. @@ -20,6 +21,7 @@ type Config struct { WorkDir string // directory where files needed for the execution are stored RuntimeDir string // directory where the executable can be found ExecutableName string // name for the executable + DriversRootPath string // where are cgi drivers stored FS afero.Fs // FS accessor Limiter Limiter // Resource limiter for executed processes } diff --git a/executor/executor.go b/executor/executor.go index da8c42e5..5fe32ad6 100644 --- a/executor/executor.go +++ b/executor/executor.go @@ -39,6 +39,9 @@ func New(log zerolog.Logger, options ...Option) (*Executor, error) { } cfg.RuntimeDir = runtime + // todo: fix for windows + cfg.DriversRootPath = cfg.RuntimeDir + "/extensions" + // Verify the runtime path is valid. cliPath := filepath.Join(cfg.RuntimeDir, cfg.ExecutableName) _, err = cfg.FS.Stat(cliPath) diff --git a/executor/runtime_flags.go b/executor/runtime_flags.go index 6cc1ca08..099d3366 100644 --- a/executor/runtime_flags.go +++ b/executor/runtime_flags.go @@ -29,6 +29,10 @@ func runtimeFlags(cfg execute.BLSRuntimeConfig, permissions []string) []string { flags = append(flags, "--"+execute.BLSRuntimeFlagFSRoot, cfg.FSRoot) } + if cfg.DriversRootPath != "" { + flags = append(flags, "--"+execute.BLSRuntimeFlagDrivers, cfg.DriversRootPath) + } + if cfg.Fuel > 0 { flags = append(flags, "--"+execute.BLSRuntimeFlagFuel, fmt.Sprint(cfg.Fuel)) } diff --git a/models/execute/runtime.go b/models/execute/runtime.go index 64059062..1b817e98 100644 --- a/models/execute/runtime.go +++ b/models/execute/runtime.go @@ -12,6 +12,7 @@ type BLSRuntimeConfig struct { Fuel uint64 `json:"limited_fuel,omitempty"` Memory uint64 `json:"limited_memory,omitempty"` Logger string `json:"runtime_logger,omitempty"` + DriversRootPath string `json:"drivers_root_path,omitempty"` // Fields not allowed to be set in the request. Input string `json:"-"` FSRoot string `json:"-"` @@ -28,4 +29,5 @@ const ( BLSRuntimeFlagLogger = "runtime-logger" BLSRuntimeFlagPermission = "permission" BLSRuntimeFlagEnv = "env" + BLSRuntimeFlagDrivers = "drivers-root-path" )