canontech/staking-payouts

exit codes

Closed this issue · 2 comments

What are the exit codes returned by this program, and can they be used to check whether it completed successfully?

When I run the ls operation (and there are no payouts), it returns 1. Likewise for the collect operation. I can't currently test how it behaves when there are payouts.

Right now, I've had to ignore the exit code in my systemd unit because of this, but this is highly undesirable, since it means I'm ignoring actual errors too.

I honestly haven't thought about exit codes as part of the api, but we should be able to make it more helpful.

Getting into implementation details, but to better explain the current status:

ATM it should just always return 1 because of

main()
.catch(log.error)
.finally(() => {
log.info('Exiting ...');
process.exit(1);

What I can do is just make sure it always throws on an error and then return an error exit code in the catch.

Let me know what you think about the PR.