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 5 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
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
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