forked from hashicorp/nomad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
system_gc.go
54 lines (40 loc) · 1.1 KB
/
system_gc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package command
import (
"fmt"
"strings"
"github.com/posener/complete"
)
type SystemGCCommand struct {
Meta
}
func (c *SystemGCCommand) Help() string {
helpText := `
Usage: nomad system gc [options]
Initializes a garbage collection of jobs, evaluations, allocations, and nodes.
General Options:
` + generalOptionsUsage()
return strings.TrimSpace(helpText)
}
func (c *SystemGCCommand) Synopsis() string {
return "Run the system garbage collection process"
}
func (c *SystemGCCommand) AutocompleteFlags() complete.Flags {
return c.Meta.AutocompleteFlags(FlagSetClient)
}
func (c *SystemGCCommand) AutocompleteArgs() complete.Predictor {
return complete.PredictNothing
}
func (c *SystemGCCommand) Name() string { return "system gc" }
func (c *SystemGCCommand) Run(args []string) int {
// Get the HTTP client
client, err := c.Meta.Client()
if err != nil {
c.Ui.Error(fmt.Sprintf("Error initializing client: %s", err))
return 1
}
if err := client.System().GarbageCollect(); err != nil {
c.Ui.Error(fmt.Sprintf("Error running system garbage-collection: %s", err))
return 1
}
return 0
}