Skip to content

Commit

Permalink
pause now suspend command Fixes #179
Browse files Browse the repository at this point in the history
  • Loading branch information
codepope committed Jun 29, 2020
1 parent 327ce6f commit 3077670
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions api/resource_apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ func (client *Client) MoveApp(appName string, orgID string) (*App, error) {
return &data.App, err
}

// PauseApp - Send GQL mutation to pause app
func (client *Client) PauseApp(appName string) (*App, error) {
// SuspendApp - Send GQL mutation to suspend app
func (client *Client) SuspendApp(appName string) (*App, error) {
query := `
mutation ($input: PauseAppInput!) {
pauseApp(input: $input) {
Expand All @@ -241,7 +241,7 @@ func (client *Client) PauseApp(appName string) (*App, error) {
})

data, err := client.Run(req)
return &data.PauseApp.App, err
return &data.SuspendApp.App, err
}

// ResumeApp - Send GQL mutation to pause app
Expand Down
2 changes: 1 addition & 1 deletion api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ type Query struct {
App App
}

PauseApp struct {
SuspendApp struct {
App App
}

Expand Down
16 changes: 8 additions & 8 deletions cmd/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ func newAppListCommand() *Command {
Description: `The organization to move the app to`,
})

appsPauseStrings := docstrings.Get("apps.pause")
appsPauseCmd := BuildCommand(cmd, runAppsPause, appsPauseStrings.Usage, appsPauseStrings.Short, appsPauseStrings.Long, os.Stdout, requireSession, requireAppNameAsArg)
appsPauseCmd.Args = cobra.RangeArgs(0, 1)
appsSuspendStrings := docstrings.Get("apps.suspend")
appsSuspendCmd := BuildCommand(cmd, runAppsSuspend, appsSuspendStrings.Usage, appsSuspendStrings.Short, appsSuspendStrings.Long, os.Stdout, requireSession, requireAppNameAsArg)
appsSuspendCmd.Args = cobra.RangeArgs(0, 1)

appsResumeStrings := docstrings.Get("apps.resume")
appsResumeCmd := BuildCommand(cmd, runAppsResume, appsResumeStrings.Usage, appsResumeStrings.Short, appsResumeStrings.Long, os.Stdout, requireSession, requireAppNameAsArg)
Expand All @@ -105,15 +105,15 @@ func runAppsList(ctx *cmdctx.CmdContext) error {
return ctx.Render(&presenters.Apps{Apps: apps})
}

func runAppsPause(ctx *cmdctx.CmdContext) error {
func runAppsSuspend(ctx *cmdctx.CmdContext) error {
// appName := ctx.Args[0]
// fmt.Println(appName, len(ctx.Args))
// if appName == "" {
// appName = ctx.AppName
// }
appName := ctx.AppName

_, err := ctx.Client.API().PauseApp(appName)
_, err := ctx.Client.API().SuspendApp(appName)
if err != nil {
return err
}
Expand All @@ -126,20 +126,20 @@ func runAppsPause(ctx *cmdctx.CmdContext) error {

s := spinner.New(spinner.CharSets[11], 100*time.Millisecond)
s.Writer = os.Stderr
s.Prefix = fmt.Sprintf("Pausing %s with %d instances to stop ", appstatus.Name, allocount)
s.Prefix = fmt.Sprintf("Suspending %s with %d instances to stop ", appstatus.Name, allocount)
s.Start()

for allocount > 0 {
plural := ""
if allocount > 1 {
plural = "s"
}
s.Prefix = fmt.Sprintf("Pausing %s with %d instance%s to stop ", appstatus.Name, allocount, plural)
s.Prefix = fmt.Sprintf("Suspending %s with %d instance%s to stop ", appstatus.Name, allocount, plural)
appstatus, err = ctx.Client.API().GetAppStatus(ctx.AppName, false)
allocount = len(appstatus.Allocations)
}

s.FinalMSG = fmt.Sprintf("Pause complete - %s is now paused with no running instances\n", appstatus.Name)
s.FinalMSG = fmt.Sprintf("Suspend complete - %s is now suspended with no running instances\n", appstatus.Name)
s.Stop()

return nil
Expand Down
10 changes: 5 additions & 5 deletions helpgen/flyctlhelp.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@ shortHelp="Move an App to another organization"
longHelp="""The APPS MOVE command will move an application to another
organization the current user belongs to.
"""
[apps.pause]
usage="pause [APPNAME]"
shortHelp="Pause an application"
longHelp="""The APPS PAUSE command will pause an application.
[apps.suspend]
usage="suspend [APPNAME]"
shortHelp="Suspend an application"
longHelp="""The APPS SUSPEND command will suspend an application.
All allocations will be deallocated leaving the application running nowhere.
It will continue to consume networking resources (IP address). See APPS RESUME
for details on restarting it.
"""
[apps.resume]
usage="resume [APPNAME]"
shortHelp="Resume an application"
longHelp="""The APPS Resume command will restart a previously paused application.
longHelp="""The APPS RESUME command will restart a previously suspended application.
The application will resume with its original region pool and a min count of one
meaning there will be one running instance once restarted. Use SCALE SET MIN= to raise
the number of configured instances.
Expand Down

0 comments on commit 3077670

Please sign in to comment.