bcoin-org / bcoin

Javascript bitcoin library for node.js and browsers
https://bcoin.io
Other
3k stars 813 forks source link

Unexpected errors are not logged run using `--daemon` #747

Open braydonf opened 5 years ago

braydonf commented 5 years ago

Versions bcoin v1.0.2 (7ceb8874ee586eb170cf4e9bba988e8b7ba2d7a6)

Expected

Heap over allocation errors, and unexpected errors, to be captured in the debug.log or to another log file when running ./bin/bcoin --daemon.

Actual

Currently this output in not captured, and likely stdout is redirected to /dev/null when running with --daemon. The is problematic when debugging issues when running a daemon, as the error is not available, and it's unclear why the process has stopped.

Reproduce

Throw an error in a function such as node.open() in ./lib/node/fullnode.js and run bcoin with --daemon and the error will not be logged, try again without the option and the error will be logged.

braydonf commented 4 years ago

This continues to be problematic and limits the usefulness of the --daemon flag. Piping standard output to a logger will likely be the preferred way to log. A systemd, initd, kubernetes and other service scripts will be a preferable alternative to using --daemon.

braydonf commented 4 years ago

Redirecting stdout is desirable in a wide variety of use cases, from a single system process with Systemd to high-availability setups with Docker and Kubernetes. Features such as log rotation, aggregation, tagging, search indexing are included and often essential.