Converted forked process logging to use stdout. (#126)

Forked processes are now logging to stdout to avoid race conditions with hpcore log file.
This commit is contained in:
Ravin Perera
2020-09-24 10:40:17 +05:30
committed by GitHub
parent 3e2b7dbcfa
commit 5bfa722b24
5 changed files with 26 additions and 25 deletions

View File

@@ -52,7 +52,7 @@ namespace comm
{
close(read_fd);
close(write_fd);
util::kill_process(pid, false);
return -1;
}
@@ -63,7 +63,7 @@ namespace comm
{
// Websocat process.
util::unmask_signal();
close(write_pipe[1]); //parent write
close(read_pipe[0]); //parent read
@@ -85,7 +85,7 @@ namespace comm
NULL};
const int ret = execv(execv_args[0], execv_args);
LOG_ERROR << errno << ": websocat process execv failed.";
std::cerr << errno << ": websocat process execv failed.\n";
exit(1);
}
else

View File

@@ -335,7 +335,7 @@ namespace comm
execv_args[idx] = NULL;
const int ret = execv(execv_args[0], execv_args);
LOG_ERROR << errno << ": websocketd process execv failed.";
std::cerr << errno << ": websocketd process execv failed.\n";
exit(1);
}
else

View File

@@ -280,14 +280,14 @@ namespace cons
// only consider recent proposals and proposals from previous stage and current stage.
const bool keep_candidate = (time_diff < (conf::cfg.roundtime * 4)) && (stage_diff == -3 || stage_diff <= 1);
LOG_DEBUG << (keep_candidate ? "Prop--->" : "Erased")
<< " [s" << std::to_string(cp.stage)
<< "] u/i/o:" << cp.users.size()
<< "/" << cp.hash_inputs.size()
<< "/" << cp.hash_outputs.size()
<< " ts:" << std::to_string(cp.time)
<< " lcl:" << cp.lcl.substr(0, 15)
<< " state:" << cp.state
<< " [from:" << ((cp.pubkey == conf::cfg.pubkey) ? "self" : util::get_hex(cp.pubkey, 1, 5)) << "]";
<< " [s" << std::to_string(cp.stage)
<< "] u/i/o:" << cp.users.size()
<< "/" << cp.hash_inputs.size()
<< "/" << cp.hash_outputs.size()
<< " ts:" << std::to_string(cp.time)
<< " lcl:" << cp.lcl.substr(0, 15)
<< " state:" << cp.state
<< " [from:" << ((cp.pubkey == conf::cfg.pubkey) ? "self" : util::get_hex(cp.pubkey, 1, 5)) << "]";
if (keep_candidate)
++itr;
@@ -377,7 +377,7 @@ namespace cons
p2p::broadcast_message(fbuf, true);
LOG_DEBUG << "NUP sent."
<< " users:" << nup.user_inputs.size();
<< " users:" << nup.user_inputs.size();
}
/**
@@ -524,7 +524,7 @@ namespace cons
// before execution chdir into a valid the latest state data directory that contains an appbill.table
chdir(conf::ctx.state_rw_dir.c_str());
int ret = execv(execv_args[0], execv_args);
LOG_ERROR << "Appbill process execv failed: " << ret;
std::cerr << errno << ": Appbill process execv failed.\n";
return false;
}
else
@@ -667,11 +667,11 @@ namespace cons
p2p::broadcast_message(fbuf, true);
LOG_DEBUG << "Proposed u/i/o:" << p.users.size()
<< "/" << p.hash_inputs.size()
<< "/" << p.hash_outputs.size()
<< " ts:" << std::to_string(p.time)
<< " lcl:" << p.lcl.substr(0, 15)
<< " state:" << p.state;
<< "/" << p.hash_inputs.size()
<< "/" << p.hash_outputs.size()
<< " ts:" << std::to_string(p.time)
<< " lcl:" << p.lcl.substr(0, 15)
<< " state:" << p.state;
}
/**

View File

@@ -67,7 +67,7 @@ namespace hpfs
NULL};
const int ret = execv(execv_args[0], execv_args);
LOG_ERROR << errno << ": hpfs merge process execv failed.";
std::cerr << errno << ": hpfs merge process execv failed.\n";
exit(1);
}
else
@@ -165,7 +165,7 @@ namespace hpfs
NULL};
const int ret = execv(execv_args[0], execv_args);
LOG_ERROR << errno << ": hpfs session process execv failed.";
std::cerr << errno << ": hpfs session process execv failed.\n";
exit(1);
}
else

View File

@@ -26,6 +26,9 @@ namespace sc
}
int ret = 0;
LOG_DEBUG << "Starting contract process..." << (ctx.args.readonly ? " (rdonly)" : "");
const pid_t pid = fork();
if (pid > 0)
{
@@ -74,8 +77,6 @@ namespace sc
// Write the contract input message from HotPocket to the stdin (0) of the contract process.
write_contract_args(ctx);
LOG_DEBUG << "Starting contract process..." << (ctx.args.readonly ? " (rdonly)" : "");
const bool using_appbill = !ctx.args.readonly && !conf::cfg.appbill.empty();
int len = conf::cfg.runtime_binexec_args.size() + 1;
if (using_appbill)
@@ -97,7 +98,7 @@ namespace sc
chdir(ctx.args.state_dir.c_str());
int ret = execv(execv_args[0], execv_args);
LOG_ERROR << errno << ": Contract process execv failed." << (ctx.args.readonly ? " (rdonly)" : "");
std::cerr << errno << ": Contract process execv failed." << (ctx.args.readonly ? " (rdonly)" : "") << "\n";
exit(1);
}
else
@@ -160,7 +161,7 @@ namespace sc
return -1;
LOG_DEBUG << "Stopping hpfs session... pid:" << ctx.hpfs_pid << (ctx.args.readonly ? " (rdonly)" : "");
if (util::kill_process(ctx.hpfs_pid, true) == -1)
return -1;