You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by ab...@apache.org on 2023/01/10 02:51:31 UTC

[incubator-devlake] branch release-v0.14-ee updated: fix: zombie process by docker file

This is an automated email from the ASF dual-hosted git repository.

abeizn pushed a commit to branch release-v0.14-ee
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/release-v0.14-ee by this push:
     new a1635ffee fix: zombie process by docker file
a1635ffee is described below

commit a1635ffeef3bb1451ded755db7c86540fedd7556
Author: abeizn <zi...@merico.dev>
AuthorDate: Tue Jan 10 10:51:23 2023 +0800

    fix: zombie process by docker file
---
 Dockerfile                     | 6 ++++++
 plugins/dbt/dbt.go             | 2 ++
 plugins/dbt/tasks/convertor.go | 9 +++++++--
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index e3aeb0dd5..0ec07049a 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -48,6 +48,12 @@ COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
 
 ENV PATH="/app/bin:${PATH}"
 
+# add tini
+ENV TINI_VERSION v0.19.0
+ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
+RUN chmod +x /tini
+ENTRYPOINT ["/tini", "--"]
+
 CMD ["lake"]
 
 # Notes: Docker for Mac(M1) sets up qemu emulation, you can try to use the amd64 image by adding the --platform=linux/amd64 flag. 
diff --git a/plugins/dbt/dbt.go b/plugins/dbt/dbt.go
index 3fc6f5ef9..1a5e4b7b3 100644
--- a/plugins/dbt/dbt.go
+++ b/plugins/dbt/dbt.go
@@ -87,6 +87,7 @@ func main() {
 	failFast := dbtCmd.Flags().BoolP("failFast", "", false, "dbt fail fast")
 	profilesPath := dbtCmd.Flags().StringP("profilesPath", "", "/Users/abeizn/.dbt", "dbt profiles path")
 	profile := dbtCmd.Flags().StringP("profile", "", "default", "dbt profile")
+	threads := dbtCmd.Flags().IntP("threads", "", 1, "dbt threads")
 	noVersionCheck := dbtCmd.Flags().BoolP("noVersionCheck", "", false, "dbt no version check")
 	excludeModels := dbtCmd.Flags().StringSliceP("excludeModels", "", []string{}, "dbt exclude models")
 	selector := dbtCmd.Flags().StringP("selector", "", "", "dbt selector")
@@ -116,6 +117,7 @@ func main() {
 			"failFast":       *failFast,
 			"profilesPath":   *profilesPath,
 			"profile":        *profile,
+			"threads":        *threads,
 			"noVersionCheck": *noVersionCheck,
 			"excludeModels":  *excludeModels,
 			"selector":       *selector,
diff --git a/plugins/dbt/tasks/convertor.go b/plugins/dbt/tasks/convertor.go
index da4169563..2cef1df3a 100644
--- a/plugins/dbt/tasks/convertor.go
+++ b/plugins/dbt/tasks/convertor.go
@@ -45,6 +45,7 @@ func DbtConverter(taskCtx core.SubTaskContext) errors.Error {
 	projectVars := data.Options.ProjectVars
 	args := data.Options.Args
 	failFast := data.Options.FailFast
+	threads := data.Options.Threads
 	noVersionCheck := data.Options.NoVersionCheck
 	excludeModels := data.Options.ExcludeModels
 	selector := data.Options.Selector
@@ -127,8 +128,8 @@ func DbtConverter(taskCtx core.SubTaskContext) errors.Error {
 		}
 
 	}
-	//set default threads = 1, prevent dbt threads can not release, so occur zombie process
-	dbtExecParams := []string{"dbt", "run", "--project-dir", projectPath, "--threads", "1"}
+
+	dbtExecParams := []string{"dbt", "run", "--project-dir", projectPath}
 	if projectVars != nil {
 		jsonProjectVars, err := json.Marshal(projectVars)
 		if err != nil {
@@ -147,6 +148,10 @@ func DbtConverter(taskCtx core.SubTaskContext) errors.Error {
 	if failFast {
 		dbtExecParams = append(dbtExecParams, "--fail-fast")
 	}
+	if threads != 0 {
+		dbtExecParams = append(dbtExecParams, "--threads")
+		dbtExecParams = append(dbtExecParams, strconv.Itoa(threads))
+	}
 	if noVersionCheck {
 		dbtExecParams = append(dbtExecParams, "--no-version-check")
 	}