The failed_when condition change is needed to weed out 'false errors` that come up.
Scenario 1
The command actually runs successfully. This means that the pm2_start.rc will be 0, so we will immediately not meet the new failure requirement on the first AND condition.
Scenario 2
The command actually fails, maybe a command not found error or something. This WILL meet the first condition with .rc being non-zero, AND the text 'Script already launched' will also be not in the err text, correctly erroring on this scenario.
Scenario 3
The command 'fails' but is due to pm2 already running. This will meet the first error criteria of .rc != 0 but since the stderr will have the 'Script already launched' text, we will NOT meet both failure criteria and this will be seen as a success.
The
failed_when
condition change is needed to weed out 'false errors` that come up.Scenario 1
The command actually runs successfully. This means that the
pm2_start.rc
will be 0, so we will immediately not meet the new failure requirement on the first AND condition.Scenario 2
The command actually fails, maybe a
command not found
error or something. This WILL meet the first condition with.rc
being non-zero, AND the text 'Script already launched' will also benot in
the err text, correctly erroring on this scenario.Scenario 3
The command 'fails' but is due to pm2 already running. This will meet the first error criteria of
.rc != 0
but since the stderrwill
have the 'Script already launched' text, we will NOT meet both failure criteria and this will be seen as a success.