From 517cabfcd35bd77427452cb6d565424faa6f9a55 Mon Sep 17 00:00:00 2001 From: marvzhang Date: Mon, 30 Mar 2020 12:57:43 +0800 Subject: [PATCH] fixed https://github.com/crawlab-team/crawlab/issues/659 --- backend/services/task.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/services/task.go b/backend/services/task.go index 07e9ab07..0a9392f9 100644 --- a/backend/services/task.go +++ b/backend/services/task.go @@ -23,6 +23,7 @@ import ( "runtime" "runtime/debug" "strconv" + "strings" "sync" "syscall" "time" @@ -113,7 +114,9 @@ func SetEnv(cmd *exec.Cmd, envs []model.Env, task model.Task, spider model.Spide homePath := os.Getenv("HOME") nodeVersion := "v8.12.0" nodePath := path.Join(homePath, ".nvm/versions/node", nodeVersion, "lib/node_modules") - _ = os.Setenv("PATH", nodePath+":"+envPath) + if !strings.Contains(envPath, nodePath) { + _ = os.Setenv("PATH", nodePath+":"+envPath) + } _ = os.Setenv("NODE_PATH", nodePath) // 默认环境变量