From db55743e8f412b36972ce31f632b51f526f72152 Mon Sep 17 00:00:00 2001 From: julien Date: Wed, 5 Dec 2018 17:56:23 +0300 Subject: [PATCH] Ignore unreachable client error --- cmd/sup/main.go | 3 +++ sup.go | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/cmd/sup/main.go b/cmd/sup/main.go index e1f35ee..6a074aa 100644 --- a/cmd/sup/main.go +++ b/cmd/sup/main.go @@ -26,6 +26,7 @@ var ( debug bool disablePrefix bool + ignoreError bool showVersion bool showHelp bool @@ -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") @@ -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...) diff --git a/sup.go b/sup.go index d815068..486f3a4 100644 --- a/sup.go +++ b/sup.go @@ -19,6 +19,7 @@ type Stackup struct { conf *Supfile debug bool prefix bool + ignore bool } func New(conf *Supfile) (*Stackup, error) { @@ -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. @@ -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 +}