beekeeper | wrong notification while opening second bk instance
There is a problem while opening the second instance of bk pointing to the same storage. In such a scenario, the second instance should send a notification Opening beekeeper failed
yet, it now sends interrupted
.
It is because the variable string error_notifications_endpoint
that should hold the address of the notification server is empty. I added a log entry to send_fail_notification
function to verify it :
void beekeeper_instance::send_fail_notification()
{
fc::variant _pid = read_file( pid_file );
fc::variant _connection = read_file( connection_file );
auto _map_pid = _pid.as<std::map<std::string, std::string>>();
auto __pid = _map_pid["pid"];
hive::utilities::notifications::notification_handler_wrapper _notification_handler;
if (error_notifications_endpoint.empty()) {
elog("error_notifications_endpoint is empty !");
}
_notification_handler.register_endpoint( error_notifications_endpoint );
appbase::application::dynamic_notify( _notification_handler, "Opening beekeeper failed", "pid", __pid, "connection", _connection );
}
Below we have logs from the second instance:
2401520ms json_rpc_plugin.cpp:238 initialize ] initializing JSON RPC plugin
2401520ms json_rpc_plugin.cpp:200 add_api_method ] api_name: jsonrpc method_name: get_methods
2401520ms json_rpc_plugin.cpp:200 add_api_method ] api_name: jsonrpc method_name: get_signature
2401520ms webserver_plugin.cpp:587 plugin_initialize ] initializing webserver plugin
2401520ms webserver_plugin.cpp:590 plugin_initialize ] configured with 1 thread pool size
2401520ms webserver_plugin.cpp:593 plugin_initialize ] Compression in webserver is disabled
2401520ms webserver_plugin.cpp:605 plugin_initialize ] configured http to listen on 0.0.0.0:0
2401520ms beekeeper_app_init.cpp:49 initialize_program_o ] initializing options
2401520ms notifications.cpp:65 setup ] setting up notification handler for 1 address
2401523ms beekeeper_instance.cpp:69 initialize_lock ] Failed to lock access to wallet directory; is another `beekeeper` running?
**2401523ms beekeeper_instance.cpp:144 send_fail_notificati ] error_notifications_endpoint is empty !**
2402692ms notifications.cpp:46 operator() ] notification error: `unspecified:Connection refused `
2402692ms notifications.cpp:127 broadcast ] Establishing a connection with an address 127.0.0.1:45801 failed
The interesting fact is that interupt signal is sent back to the notification server:
Got notification: {'value': {'current_status': 'interrupted'}, 'time': '2023-12-06T07:40:47', 'name': 'hived_status'}
Beekeeper startup interrupted
Details : {'current_status': 'interrupted'