feat: add ability to scope retire call to a single app
Also cleanup the log output a bit for the ps:retire command.
This commit is contained in:
@@ -56,7 +56,8 @@ func main() {
|
||||
case "retire":
|
||||
args := flag.NewFlagSet("ps:retire", flag.ExitOnError)
|
||||
args.Parse(os.Args[2:])
|
||||
err = ps.CommandRetire()
|
||||
appName := args.Arg(0)
|
||||
err = ps.CommandRetire(appName)
|
||||
case "scale":
|
||||
args := flag.NewFlagSet("ps:scale", flag.ExitOnError)
|
||||
skipDeploy := args.Bool("skip-deploy", false, "--skip-deploy: skip deploy of the app")
|
||||
|
||||
@@ -93,9 +93,14 @@ func CommandRestore(appName string, allApps bool, parallelCount int) error {
|
||||
}
|
||||
|
||||
// CommandRetire ensures old containers are retired
|
||||
func CommandRetire() error {
|
||||
func CommandRetire(appName string) error {
|
||||
lockFile := filepath.Join(common.MustGetEnv("DOKKU_LIB_ROOT"), "data", "ps", "retire")
|
||||
scheduler := common.GetGlobalScheduler()
|
||||
scheduler := ""
|
||||
if appName == "" {
|
||||
scheduler = common.GetGlobalScheduler()
|
||||
} else {
|
||||
scheduler = common.GetAppScheduler(appName)
|
||||
}
|
||||
|
||||
fileLock := flock.New(lockFile)
|
||||
locked, err := fileLock.TryLock()
|
||||
@@ -108,7 +113,8 @@ func CommandRetire() error {
|
||||
return fmt.Errorf("Failed to acquire ps:retire lock")
|
||||
}
|
||||
|
||||
if err := common.PlugnTrigger("scheduler-retire", []string{scheduler}...); err != nil {
|
||||
common.LogInfo1("Retiring old containers and images")
|
||||
if err := common.PlugnTrigger("scheduler-retire", []string{scheduler, appName}...); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user