Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore unreachable client error #152

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions cmd/sup/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var (

debug bool
disablePrefix bool
ignoreError bool

showVersion bool
showHelp bool
Expand Down Expand Up @@ -60,6 +61,7 @@ func init() {
flag.BoolVar(&debug, "D", false, "Enable debug mode")
flag.BoolVar(&debug, "debug", false, "Enable debug mode")
flag.BoolVar(&disablePrefix, "disable-prefix", false, "Disable hostname prefix")
flag.BoolVar(&ignoreError, "ignore-error", false, "Ignore unreachable client error")

flag.BoolVar(&showVersion, "v", false, "Print version")
flag.BoolVar(&showVersion, "version", false, "Print version")
Expand Down Expand Up @@ -373,6 +375,7 @@ func main() {
}
app.Debug(debug)
app.Prefix(!disablePrefix)
app.Ignore(ignoreError)

// Run all the commands in the given network.
err = app.Run(network, vars, commands...)
Expand Down
11 changes: 10 additions & 1 deletion sup.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Stackup struct {
conf *Supfile
debug bool
prefix bool
ignore bool
}

func New(conf *Supfile) (*Stackup, error) {
Expand Down Expand Up @@ -106,7 +107,11 @@ func (sup *Stackup) Run(network *Network, envVars EnvList, commands ...*Command)
clients = append(clients, client)
}
for err := range errCh {
return errors.Wrap(err, "connecting to clients failed")
if sup.ignore {
fmt.Fprintf(os.Stderr, "%v\n", errors.Wrap(err, "connecting to clients failed"))
} else {
return errors.Wrap(err, "connecting to clients failed")
}
}

// Run command or run multiple commands defined by target sequentially.
Expand Down Expand Up @@ -247,3 +252,7 @@ func (sup *Stackup) Debug(value bool) {
func (sup *Stackup) Prefix(value bool) {
sup.prefix = value
}

func (sup *Stackup) Ignore(value bool) {
sup.ignore = value
}