这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions plugins/ps/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,28 @@ var (
}
)

// RetireLockFailed wraps error to distinguish between a normal error
// and an error where the retire lock could not be fetched
type RetireLockFailed struct {
Err *error
}

// ExitCode returns an exit code to use in case this error bubbles
// up into an os.Exit() call
func (err *RetireLockFailed) ExitCode() int {
return 137
}

// Error returns a standard non-existent app error
func (err *RetireLockFailed) Error() string {
if err.Err != nil {
e := *err.Err
return fmt.Sprintf("Failed to acquire ps:retire lock: %s", e.Error())
}

return fmt.Sprintf("Failed to acquire ps:retire lock")
}

// Formation contains scaling information for a given process type
type Formation struct {
ProcessType string `json:"process_type"`
Expand Down
4 changes: 2 additions & 2 deletions plugins/ps/subcommands.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ func CommandRetire(appName string) error {
fileLock := flock.New(lockFile)
locked, err := fileLock.TryLock()
if err != nil {
return fmt.Errorf("Failed to acquire ps:retire lock: %s", err)
return &RetireLockFailed{&err}
}
defer fileLock.Unlock()

if !locked {
return fmt.Errorf("Failed to acquire ps:retire lock")
return &RetireLockFailed{}
}

common.LogInfo1("Retiring old containers and images")
Expand Down
1 change: 1 addition & 0 deletions plugins/scheduler-docker-local/install
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ After=docker.service
Type=oneshot
User=$DOKKU_SYSTEM_USER
ExecStart=$DOKKU_PATH ps:retire
SuccessExitStatus=137

[Install]
WantedBy=docker.service
Expand Down