Skip to content

Commit

Permalink
FIX eclair-cli error code in case of HTTP problem
Browse files Browse the repository at this point in the history
Last command of eclair-cli is a curl piped to jq. In case of an
error with the curl command (for instance, eclair service is not
running) the error code was swallowed by the pipe wich will
return the exit code of the last command of the pipe (here, jq).

Setting `pipefail` ensures that the error code of curl is
preserve in case of HTTP issue.

This can come handy, for instance, to check that eclair is not
ok:

```
if eclair-cli getinfo
then
  echo eclair is answering
else
  echo problem communicating with eclair
fi
```
  • Loading branch information
pgrange committed Dec 8, 2023
1 parent be4ed3c commit 6b76fa5
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions eclair-core/eclair-cli
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,5 @@ else
fi

# we're now ready to execute the API call
set -o pipefail # ensures we preserve curl error code in case of HTTP issue
eval curl "--user $auth --silent --show-error -X POST -H \"Content-Type: application/x-www-form-urlencoded\" $api_payload $api_url/$api_endpoint" | jq -r "$jq_filter"

0 comments on commit 6b76fa5

Please sign in to comment.