shmmonitor: daemon output to file if FAIRMQ_SHMMONITOR_VERBOSE is true

This commit is contained in:
Alexey Rybalchenko 2021-03-31 12:53:11 +02:00
parent e708a59c48
commit f1a57f52f1
2 changed files with 13 additions and 1 deletions

View File

@ -227,8 +227,15 @@ class Manager
boost::filesystem::path p = boost::process::search_path("fairmq-shmmonitor", ownPath);
bool verbose = false;
if (const char* verboseEnv = getenv("FAIRMQ_SHMMONITOR_VERBOSE")) {
if (std::string(verboseEnv) == "true") {
verbose = true;
}
}
if (!p.empty()) {
boost::process::spawn(p, "-x", "-m", "--shmid", id, "-d", "-t", "2000", env);
boost::process::spawn(p, "-x", "-m", "--shmid", id, "-d", "-t", "2000", verbose ? "--verbose" : "", env);
int numTries = 0;
do {
try {

View File

@ -86,6 +86,7 @@ int main(int argc, char** argv)
bool debug = false;
bool cleanOnExit = false;
bool getShmId = false;
bool verbose = false;
int userId = -1;
options_description desc("Options");
@ -103,6 +104,7 @@ int main(int argc, char** argv)
("clean-on-exit,e", value<bool>(&cleanOnExit)->implicit_value(true), "Perform cleanup on exit")
("interval" , value<unsigned int>(&intervalInMS)->default_value(100), "Output interval for interactive mode")
("get-shmid" , value<bool>(&getShmId)->implicit_value(true), "Translate given session id and user id to a shmem id (uses current user id if none provided)")
("verbose" , value<bool>(&verbose)->implicit_value(true), "Verbose mode (daemon will output to a file 'fairmq-shmmonitor_log_<timestamp>')")
("user-id" , value<int>(&userId)->default_value(-1), "User id (used with --get-shmid)")
("help,h", "Print help");
@ -117,6 +119,9 @@ int main(int argc, char** argv)
notify(vm);
if (runAsDaemon) {
if (verbose) {
fair::Logger::InitFileSink("trace", "fairmq-shmmonitor_log");
}
daemonize();
}