feat: allow specifying a single process type to restart
This changes restarts to drop the 'release' part that currently gets triggered, which also helps reduce the possibility that a new image layer will be added due to predeploy deploy triggers. Note that the old method essentially halfway-rebuilt the app (which was what added the extra layer). This refactor removes that, which is a bc-break. Additionally, scaling processes will result in deploying _only_ restarting the processes being scaled. Closes #2184
This commit is contained in:
@@ -282,12 +282,18 @@ func scaleSet(appName string, skipDeploy bool, clearExisting bool, processTuples
|
||||
return nil
|
||||
}
|
||||
|
||||
imageTag, err := common.GetRunningImageTag(appName)
|
||||
imageTag, err := common.GetRunningImageTag(appName, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return common.PlugnTrigger("release-and-deploy", []string{appName, imageTag}...)
|
||||
for _, formation := range formations {
|
||||
if err := common.PlugnTrigger("deploy", []string{appName, imageTag, formation.ProcessType}...); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func updateScale(appName string, clearExisting bool, formationUpdates FormationSlice) error {
|
||||
|
||||
@@ -57,7 +57,37 @@ func Restart(appName string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
return common.PlugnTrigger("release-and-deploy", []string{appName}...)
|
||||
imageTag, err := common.GetRunningImageTag(appName, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if imageTag == "" {
|
||||
common.LogWarn("No deployed-image-tag property saved, falling back to full release-and-deploy")
|
||||
return common.PlugnTrigger("release-and-deploy", []string{appName}...)
|
||||
}
|
||||
|
||||
return common.PlugnTrigger("deploy", []string{appName, imageTag}...)
|
||||
}
|
||||
|
||||
// RestartProcess restarts a process type within an app
|
||||
func RestartProcess(appName string, processName string) error {
|
||||
if !common.IsDeployed(appName) {
|
||||
common.LogWarn(fmt.Sprintf("App %s has not been deployed", appName))
|
||||
return nil
|
||||
}
|
||||
|
||||
imageTag, err := common.GetRunningImageTag(appName, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if imageTag == "" {
|
||||
common.LogWarn("No deployed-image-tag property saved, falling back to full release-and-deploy")
|
||||
return common.PlugnTrigger("release-and-deploy", []string{appName}...)
|
||||
}
|
||||
|
||||
return common.PlugnTrigger("deploy", []string{appName, imageTag, processName}...)
|
||||
}
|
||||
|
||||
// Restore ensures an app that should be running is running on boot
|
||||
@@ -90,7 +120,7 @@ func Restore(appName string) error {
|
||||
|
||||
// Start starts the app
|
||||
func Start(appName string) error {
|
||||
imageTag, _ := common.GetRunningImageTag(appName)
|
||||
imageTag, _ := common.GetRunningImageTag(appName, "")
|
||||
|
||||
if !common.IsDeployed(appName) {
|
||||
common.LogWarn(fmt.Sprintf("App %s has not been deployed", appName))
|
||||
|
||||
@@ -21,7 +21,7 @@ Additional commands:`
|
||||
ps:inspect <app>, Displays a sanitized version of docker inspect for an app
|
||||
ps:rebuild [--parallel count] [--all|<app>], Rebuilds an app from source
|
||||
ps:report [<app>] [<flag>], Displays a process report for one or more apps
|
||||
ps:restart [--parallel count] [--all|<app>], Restart an app
|
||||
ps:restart [--parallel count] [--all|<app>] [<process-name>], Restart an app
|
||||
ps:restore [<app>], Start previously running apps e.g. after reboot
|
||||
ps:scale [--skip-deploy] <app> <proc>=<count> [<proc>=<count>...], Get/Set how many instances of a given process to run
|
||||
ps:set <app> <key> <value>, Set or clear a ps property for an app
|
||||
|
||||
@@ -45,7 +45,8 @@ func main() {
|
||||
parallelCount := args.Int("parallel", ps.RunInSerial, "--parallel: number of apps to restart in parallel, -1 to match cpu count")
|
||||
args.Parse(os.Args[2:])
|
||||
appName := args.Arg(0)
|
||||
err = ps.CommandRestart(appName, *allApps, *parallelCount)
|
||||
processName := args.Arg(1)
|
||||
err = ps.CommandRestart(appName, processName, *allApps, *parallelCount)
|
||||
case "restore":
|
||||
args := flag.NewFlagSet("ps:restore", flag.ExitOnError)
|
||||
allApps := args.Bool("all", false, "--all: restore all apps")
|
||||
|
||||
@@ -54,8 +54,11 @@ func CommandReport(appName string, format string, infoFlag string) error {
|
||||
}
|
||||
|
||||
// CommandRestart restarts an app
|
||||
func CommandRestart(appName string, allApps bool, parallelCount int) error {
|
||||
func CommandRestart(appName string, processName string, allApps bool, parallelCount int) error {
|
||||
if allApps {
|
||||
if processName != "" {
|
||||
return errors.New("Unable to restart all apps when specifying a process name")
|
||||
}
|
||||
return common.RunCommandAgainstAllApps(Restart, "restart", parallelCount)
|
||||
}
|
||||
|
||||
@@ -63,6 +66,10 @@ func CommandRestart(appName string, allApps bool, parallelCount int) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if processName != "" {
|
||||
return RestartProcess(appName, processName)
|
||||
}
|
||||
|
||||
return Restart(appName)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user