Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Reinitialize net plugin logger on HUP #6791

Merged
merged 6 commits into from
Feb 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libraries/appbase
8 changes: 6 additions & 2 deletions plugins/bnet_plugin/bnet_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1342,8 +1342,7 @@ namespace eosio {
}

void bnet_plugin::plugin_startup() {
if(fc::get_logger_map().find(logger_name) != fc::get_logger_map().end())
plugin_logger = fc::get_logger_map()[logger_name];
handle_sighup(); // Sets logger

wlog( "bnet startup " );

Expand Down Expand Up @@ -1440,6 +1439,11 @@ namespace eosio {
// lifetime of _ioc is guarded by shared_ptr of bnet_plugin_impl
}

void bnet_plugin::handle_sighup() {
if(fc::get_logger_map().find(logger_name) != fc::get_logger_map().end())
plugin_logger = fc::get_logger_map()[logger_name];
}


session::~session() {
wlog( "close session ${n}",("n",_session_num) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class bnet_plugin : public plugin<bnet_plugin> {
void plugin_initialize(const variables_map& options);
void plugin_startup();
void plugin_shutdown();
void handle_sighup() override;

private:
bnet_ptr my;
Expand Down
1 change: 1 addition & 0 deletions plugins/net_plugin/include/eosio/net_plugin/net_plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace eosio {

APPBASE_PLUGIN_REQUIRES((chain_plugin))
virtual void set_program_options(options_description& cli, options_description& cfg) override;
void handle_sighup() override;

void plugin_initialize(const variables_map& options);
void plugin_startup();
Expand Down
3 changes: 3 additions & 0 deletions plugins/net_plugin/net_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3058,7 +3058,10 @@ namespace eosio {
for( auto seed_node : my->supplied_peers ) {
connect( seed_node );
}
handle_sighup();
}

void net_plugin::handle_sighup() {
if(fc::get_logger_map().find(logger_name) != fc::get_logger_map().end())
logger = fc::get_logger_map()[logger_name];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class producer_plugin : public appbase::plugin<producer_plugin> {
virtual void plugin_initialize(const boost::program_options::variables_map& options);
virtual void plugin_startup();
virtual void plugin_shutdown();
void handle_sighup() override;

void pause();
void resume();
Expand Down
19 changes: 11 additions & 8 deletions plugins/producer_plugin/producer_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -738,14 +738,7 @@ void producer_plugin::plugin_initialize(const boost::program_options::variables_

void producer_plugin::plugin_startup()
{ try {
auto& logger_map = fc::get_logger_map();
if(logger_map.find(logger_name) != logger_map.end()) {
_log = logger_map[logger_name];
}

if( logger_map.find(trx_trace_logger_name) != logger_map.end()) {
_trx_trace_log = logger_map[trx_trace_logger_name];
}
handle_sighup(); // Sets loggers

ilog("producer plugin: plugin_startup() begin");

Expand Down Expand Up @@ -799,6 +792,16 @@ void producer_plugin::plugin_shutdown() {
my->_irreversible_block_connection.reset();
}

void producer_plugin::handle_sighup() {
auto& logger_map = fc::get_logger_map();
if(logger_map.find(logger_name) != logger_map.end()) {
_log = logger_map[logger_name];
}
if( logger_map.find(trx_trace_logger_name) != logger_map.end()) {
_trx_trace_log = logger_map[trx_trace_logger_name];
}
}

void producer_plugin::pause() {
my->_pause_production = true;
}
Expand Down
23 changes: 8 additions & 15 deletions programs/nodeos/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,14 @@ void configure_logging(const bfs::path& config_path)

} // namespace detail

void logging_conf_loop()
void logging_conf_handler()
{
std::shared_ptr<boost::asio::signal_set> sighup_set(new boost::asio::signal_set(app().get_io_service(), SIGHUP));
sighup_set->async_wait([sighup_set](const boost::system::error_code& err, int /*num*/) {
if(!err)
{
ilog("Received HUP. Reloading logging configuration.");
auto config_path = app().get_logging_conf();
if(fc::exists(config_path))
::detail::configure_logging(config_path);
for(auto iter : fc::get_appender_map())
iter.second->initialize(app().get_io_service());
logging_conf_loop();
}
});
ilog("Received HUP. Reloading logging configuration.");
auto config_path = app().get_logging_conf();
if(fc::exists(config_path))
::detail::configure_logging(config_path);
for(auto iter : fc::get_appender_map())
iter.second->initialize(app().get_io_service());
}

void initialize_logging()
Expand All @@ -74,7 +67,7 @@ void initialize_logging()
for(auto iter : fc::get_appender_map())
iter.second->initialize(app().get_io_service());

logging_conf_loop();
app().set_sighup_callback(logging_conf_handler);
}

enum return_codes {
Expand Down