Make the watch command propagate child exit codes
- Dominant language
- Go
- Stars
- 30.1k
- Forks
- 4.6k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 43
Description
Right now (as of 0.9.3), `consul watch` doesn't return the exit code of it's handler. E.g.
```shell
$ consul watch -prefix foo/bar sh -c 'echo foo; exit 3'; echo $?
Error executing handler: exit status 3
1
```
This makes it difficult to integrate consul watch into a supervisor process that takes certain actions or not (e.g. restart or not) based on exit codes.
`consul lock` has a parameter `-child-exit-code` which, when enabled, causes `consul lock` to exit with code 2 when the child handler exits with an error code. This isn't quite what I'm looking for: what would be ideal is a parameter like `-child-exit-code-exact` which would return the exact exit code of the child, e.g.
```shell
$ consul watch -prefix foo/bar -child-exit-code-exact sh -c 'echo foo; exit 3'; echo $?
Error executing handler: exit status 3
3
```
Contributor guide
Assessment
This issue has not been assessed yet.