(appGUID string, username string)
| 89 | } |
| 90 | |
| 91 | func (cmd ScaleCommand) scaleProcess(appGUID string, username string) (bool, error) { |
| 92 | cmd.UI.DisplayTextWithFlavor("Scaling app {{.AppName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...", map[string]interface{}{ |
| 93 | "AppName": cmd.RequiredArgs.AppName, |
| 94 | "OrgName": cmd.Config.TargetedOrganization().Name, |
| 95 | "SpaceName": cmd.Config.TargetedSpace().Name, |
| 96 | "Username": username, |
| 97 | }) |
| 98 | cmd.UI.DisplayNewline() |
| 99 | |
| 100 | shouldRestart := cmd.shouldRestart() |
| 101 | if shouldRestart && !cmd.Force { |
| 102 | shouldScale, err := cmd.UI.DisplayBoolPrompt( |
| 103 | false, |
| 104 | "This will cause the app to restart. Are you sure you want to scale {{.AppName}}?", |
| 105 | map[string]interface{}{"AppName": cmd.RequiredArgs.AppName}) |
| 106 | if err != nil { |
| 107 | return false, err |
| 108 | } |
| 109 | |
| 110 | if !shouldScale { |
| 111 | cmd.UI.DisplayText("Scaling cancelled") |
| 112 | return false, nil |
| 113 | } |
| 114 | cmd.UI.DisplayNewline() |
| 115 | } |
| 116 | |
| 117 | warnings, err := cmd.Actor.ScaleProcessByApplication(appGUID, resources.Process{ |
| 118 | Type: cmd.ProcessType, |
| 119 | Instances: cmd.Instances.NullInt, |
| 120 | MemoryInMB: cmd.MemoryLimit.NullUint64, |
| 121 | DiskInMB: cmd.DiskLimit.NullUint64, |
| 122 | LogRateLimitInBPS: types.NullInt(cmd.LogRateLimit), |
| 123 | }) |
| 124 | cmd.UI.DisplayWarnings(warnings) |
| 125 | if err != nil { |
| 126 | return false, err |
| 127 | } |
| 128 | |
| 129 | if shouldRestart { |
| 130 | err := cmd.restartApplication(appGUID, username) |
| 131 | if err != nil { |
| 132 | return false, err |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | return true, nil |
| 137 | } |
| 138 | |
| 139 | func (cmd ScaleCommand) restartApplication(appGUID string, username string) error { |
| 140 | cmd.UI.DisplayTextWithFlavor("Stopping app {{.AppName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...", map[string]interface{}{ |
no test coverage detected