Added file log.

This commit is contained in:
Ravin Perera
2019-10-21 13:29:52 +05:30
parent 2d5d8960c0
commit f77dae2f28
6 changed files with 60 additions and 11 deletions

View File

@@ -62,6 +62,22 @@ int parse_cmd(int argc, char **argv)
return -1;
}
/**
* Performs any cleanup on graceful application termination.
*/
void deinit()
{
usr::deinit();
hplog::deinit();
}
void signal_handler(int signum)
{
LOG_WARN << "Interrupt signal (" << signum << ") received.";
deinit();
exit(signum);
}
int main(int argc, char **argv)
{
// Extract the CLI args
@@ -101,7 +117,7 @@ int main(int argc, char **argv)
else if (conf::ctx.command == "run")
{
// In order to host the contract we should init some required sub systems.
if (conf::init() != 0)
return -1;
@@ -110,6 +126,9 @@ int main(int argc, char **argv)
if (usr::init() != 0)
return -1;
// After initializing primary subsystems, register the SIGINT handler.
signal(SIGINT, signal_handler);
// This will start hosting the contract and start consensus rounds.
// TODO
@@ -156,7 +175,7 @@ int main(int argc, char **argv)
}
// Free resources.
usr::deinit();
deinit();
}
}
}