feat: skip scaled processes that are missing in the Procfile

This allows folks to deploy apps that don't have a web process without needing to scale that process down before/after the first deploy. Note that the formations key in the app.json or a manual scale of other processes will be necessary to start anything non-web.

Closes #5700
This commit is contained in:
Jose Diaz-Gonzalez
2023-05-28 23:22:17 -04:00
parent 64f0f2674d
commit eb6f85f083
8 changed files with 60 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
SUBCOMMANDS = subcommands/inspect subcommands/rebuild subcommands/report subcommands/restart subcommands/restore subcommands/retire subcommands/scale subcommands/set subcommands/start subcommands/stop
TRIGGERS = triggers/app-restart triggers/core-post-deploy triggers/core-post-extract triggers/install triggers/post-app-clone triggers/post-app-clone-setup triggers/post-app-rename triggers/post-app-rename-setup triggers/post-create triggers/post-delete triggers/post-stop triggers/pre-deploy triggers/procfile-get-command triggers/ps-can-scale triggers/ps-current-scale triggers/ps-set-scale triggers/report
TRIGGERS = triggers/app-restart triggers/core-post-deploy triggers/core-post-extract triggers/install triggers/post-app-clone triggers/post-app-clone-setup triggers/post-app-rename triggers/post-app-rename-setup triggers/post-create triggers/post-delete triggers/post-stop triggers/pre-deploy triggers/procfile-get-command triggers/procfile-exists triggers/ps-can-scale triggers/ps-current-scale triggers/ps-set-scale triggers/report
BUILD = commands subcommands triggers
PLUGIN_NAME = ps

View File

@@ -64,6 +64,9 @@ func main() {
processType := flag.Arg(1)
port := common.ToInt(flag.Arg(2), 5000)
err = ps.TriggerProcfileGetCommand(appName, processType, port)
case "procfile-exists":
appName := flag.Arg(0)
err = ps.TriggerProcfileExists(appName)
case "ps-can-scale":
appName := flag.Arg(0)
canScale := common.ToBool(flag.Arg(1))

View File

@@ -1,6 +1,7 @@
package ps
import (
"errors"
"fmt"
"os"
"path"
@@ -259,6 +260,15 @@ func TriggerPreDeploy(appName string, imageTag string) error {
return nil
}
// TriggerProcfileExists checks if a procfile exists
func TriggerProcfileExists(appName string) error {
if hasProcfile(appName) {
return nil
}
return errors.New("Procfile does not exist")
}
// TriggerProcfileGetCommand fetches a command from the procfile
func TriggerProcfileGetCommand(appName string, processType string, port int) error {
if !hasProcfile(appName) {