diff --git a/plugins/ps/triggers.go b/plugins/ps/triggers.go index ee3f133c8..c6ef96a8e 100644 --- a/plugins/ps/triggers.go +++ b/plugins/ps/triggers.go @@ -77,15 +77,27 @@ func TriggerCorePostExtract(appName string, sourceWorkDir string) error { b, _ := common.PlugnTriggerOutput("git-get-property", []string{appName, "source-image"}...) appSourceImage := strings.TrimSpace(string(b[:])) + repoDefaultProcfilePath := path.Join(sourceWorkDir, "Procfile") if appSourceImage == "" { repoProcfilePath := path.Join(sourceWorkDir, procfilePath) if !common.FileExists(repoProcfilePath) { + if procfilePath != "Procfile" && common.FileExists(repoDefaultProcfilePath) { + if err := os.Remove(repoDefaultProcfilePath); err != nil { + return err + } + } return common.TouchFile(fmt.Sprintf("%s.missing", processSpecificProcfile)) } if err := copy.Copy(repoProcfilePath, processSpecificProcfile); err != nil { return fmt.Errorf("Unable to extract Procfile: %v", err.Error()) } + + if procfilePath != "Procfile" { + if err := copy.Copy(repoProcfilePath, repoDefaultProcfilePath); err != nil { + return fmt.Errorf("Unable to move Procfile into place: %v", err.Error()) + } + } } else { if err := common.CopyFromImage(appName, appSourceImage, procfilePath, processSpecificProcfile); err != nil { return common.TouchFile(fmt.Sprintf("%s.missing", processSpecificProcfile)) diff --git a/tests/apps/python/Procfile b/tests/apps/python/Procfile index 88d4d849f..77b9a38ff 100644 --- a/tests/apps/python/Procfile +++ b/tests/apps/python/Procfile @@ -3,11 +3,11 @@ ############################### # Procfile for development using the new threaded worker (scheduler, twitter stream and delayed job) -cron: python3 worker.py -web: python3 web.py # testing inline comment -worker: python3 worker.py +cron: python3 -u worker.py +web: python3 -u web.py first.Procfile # testing inline comment +worker: python3 -u worker.py custom: echo -n -release: python3 release.py +release: python3 -u release.py # Old version with separate processes (use this if you have issues with the threaded version) diff --git a/tests/apps/python/second.Procfile b/tests/apps/python/second.Procfile index b03a168c7..9c0e25d2e 100644 --- a/tests/apps/python/second.Procfile +++ b/tests/apps/python/second.Procfile @@ -1 +1 @@ -web: python3 web.py +web: python3 -u web.py second.Procfile diff --git a/tests/apps/python/sub-app/Procfile b/tests/apps/python/sub-app/Procfile index bb1e3346a..9512e68d7 100644 --- a/tests/apps/python/sub-app/Procfile +++ b/tests/apps/python/sub-app/Procfile @@ -1,2 +1,2 @@ web: python3 web.py -release: python3 release.py +release: python3 -u release.py diff --git a/tests/apps/python/web.py b/tests/apps/python/web.py index e14bb903c..5d7a77953 100644 --- a/tests/apps/python/web.py +++ b/tests/apps/python/web.py @@ -22,6 +22,9 @@ if __name__ == "__main__": print("Failing on startup due to FAIL_ON_STARTUP=true") sys.exit(1) + for arg in sys.argv: + print(f"Arg: {arg}") + port = int(os.getenv("PORT", 5000)) server = http.server.HTTPServer(("0.0.0.0", port), GetHandler) print("Listening on port {0}".format(port)) diff --git a/tests/unit/app-json.bats b/tests/unit/app-json.bats index 7155f59e9..3ea5fb674 100644 --- a/tests/unit/app-json.bats +++ b/tests/unit/app-json.bats @@ -52,7 +52,7 @@ teardown() { echo "status: $status" assert_success assert_output_contains "touch /app/heroku-postdeploy.test" - assert_output_contains "python3 release.py" + assert_output_contains "python3 -u release.py" } @test "(app-json) app.json scripts missing" { diff --git a/tests/unit/ps-general-2.bats b/tests/unit/ps-general-2.bats index 0fc167f5b..70a869e43 100644 --- a/tests/unit/ps-general-2.bats +++ b/tests/unit/ps-general-2.bats @@ -90,11 +90,18 @@ teardown() { } @test "(ps:set) procfile-path" { - run deploy_app dockerfile-procfile + run deploy_app python echo "output: $output" echo "status: $status" assert_success + run /bin/bash -c "dokku logs $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_output_contains "Arg: web.py" + assert_output_contains "Arg: first.Procfile" + assert_success + run /bin/bash -c "dokku ps:set $TEST_APP procfile-path nonexistent-procfile" echo "output: $output" echo "status: $status" @@ -117,6 +124,13 @@ teardown() { assert_success assert_output_contains 'SECRET_KEY:' 0 + run /bin/bash -c "dokku logs $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_output_contains "Arg: web.py" + assert_output_contains "Arg: second.Procfile" + assert_success + run /bin/bash -c "dokku ps:set $TEST_APP procfile-path" echo "output: $output" echo "status: $status" @@ -127,6 +141,13 @@ teardown() { echo "status: $status" assert_success assert_output_contains 'SECRET_KEY:' + + run /bin/bash -c "dokku logs $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_output_contains "Arg: web.py" + assert_output_contains "Arg: first.Procfile" + assert_success } @test "(ps:scale) remove zerod processes" {