prevent silent errors in daemon mode (#10007)

* prevent silent errors in daemon mode

* change author in Cargo.toml, add preamble to pipe.rs

* set the uid and gid on daemon process, fix permission errors when writing to pid file

* call setup_logger before daemonize to prevent crashing when attempting to create logfile

* map_err for calls to splice and ioctl, fix spaces in Cargo.toml

* split out daemonize to own repo

* removed util/daemonize

* renamed dep to parity-daemonize

* fix(parity-clib): enable `logger`

* bump parity-daemonize

* remove obsolete comment

Co-Authored-By: seunlanlege <seunlanlege@gmail.com>

* fix(grumbles): docs and log in ParityParams

* Add FIXME comment regarding @tomaka grumbles
* Unify logger with the C-API in ParityParams (less type-safety with more from_raw() conversions)
* Add better documentation in the `parity.h`

* Apply suggestions from code review

Co-Authored-By: seunlanlege <seunlanlege@gmail.com>

* docs(parity lib): add link to logging issue

* fix(parity-clib): JNI enable `logger`

* fix(parity-clib): update `Java example`

* Update example to the API changes
* Remove needless printouts which can be controlled via logger instead
This commit is contained in:
Seun LanLege
2019-02-01 19:31:02 +01:00
committed by Afri Schoedon
parent 12c42bce9b
commit 0f9b2218da
13 changed files with 162 additions and 70 deletions

View File

@@ -53,10 +53,8 @@ const std::vector<std::string> ws_subscriptions {
void callback(void* user_data, const char* response, size_t _len) {
Callback* cb = static_cast<Callback*>(user_data);
if (cb->type == CALLBACK_RPC) {
printf("rpc response: %s\r\n", response);
cb->counter -= 1;
} else if (cb->type == CALLBACK_WS) {
printf("websocket response: %s\r\n", response);
std::regex is_subscription ("\\{\"jsonrpc\":\"2.0\",\"result\":\"0[xX][a-fA-F0-9]{16}\",\"id\":1\\}");
if (std::regex_match(response, is_subscription) == true) {
cb->counter -= 1;
@@ -153,7 +151,8 @@ void* parity_run(std::vector<const char*> args) {
ParityParams cfg = {
.configuration = nullptr,
.on_client_restart_cb = callback,
.on_client_restart_cb_custom = nullptr
.on_client_restart_cb_custom = nullptr,
.logger = nullptr
};
std::vector<size_t> str_lens;
@@ -173,6 +172,10 @@ void* parity_run(std::vector<const char*> args) {
}
}
// enable logging but only the `rpc module` and don't write it to a file
char log_mode [] = "rpc=trace";
parity_set_logger(log_mode, strlen(log_mode), nullptr, 0, &cfg.logger);
void *parity = nullptr;
if (parity_start(&cfg, &parity) != 0) {
return nullptr;