mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
feat: add Go path configuration to task runner
- Introduced a new method configureGoPath in runner.go to set the GOPATH environment variable based on the retrieved Go path. - Updated configureEnv to call configureGoPath, ensuring the Go path is configured alongside Node.js paths. - Added a new utility function GetGoPath in config.go to retrieve the Go path from configuration, with a default fallback. - These changes enhance the task runner's environment setup by supporting Go development alongside existing Node.js configurations.
This commit is contained in:
@@ -353,6 +353,14 @@ func (r *Runner) configureNodePath() {
|
||||
_ = os.Setenv("NODE_PATH", nodePath)
|
||||
}
|
||||
|
||||
func (r *Runner) configureGoPath() {
|
||||
// Configure global go path
|
||||
goPath := utils.GetGoPath()
|
||||
if goPath != "" {
|
||||
_ = os.Setenv("GOPATH", goPath)
|
||||
}
|
||||
}
|
||||
|
||||
// configureEnv sets up the environment variables for the task process, including:
|
||||
// - Node.js paths
|
||||
// - Crawlab-specific variables
|
||||
@@ -361,6 +369,9 @@ func (r *Runner) configureEnv() {
|
||||
// Configure Node.js paths
|
||||
r.configureNodePath()
|
||||
|
||||
// Configure Go path
|
||||
r.configureGoPath()
|
||||
|
||||
// Default envs
|
||||
r.cmd.Env = os.Environ()
|
||||
r.cmd.Env = append(r.cmd.Env, "CRAWLAB_TASK_ID="+r.tid.Hex())
|
||||
|
||||
@@ -32,6 +32,7 @@ const (
|
||||
MetadataConfigName = "config.json"
|
||||
PyenvRoot = "/root/.pyenv"
|
||||
DefaultNodeModulesPath = "/usr/lib/node_modules"
|
||||
DefaultGoPath = "/root/go"
|
||||
)
|
||||
|
||||
func IsDev() bool {
|
||||
@@ -255,3 +256,10 @@ func GetNodeModulesPath() string {
|
||||
}
|
||||
return DefaultNodeModulesPath
|
||||
}
|
||||
|
||||
func GetGoPath() string {
|
||||
if res := viper.GetString("install.go.path"); res != "" {
|
||||
return res
|
||||
}
|
||||
return DefaultGoPath
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user