feat: start license server at best

This commit is contained in:
eeff
2022-08-03 18:02:44 +08:00
parent 42aa45e6f6
commit fc5dd6e56e
4 changed files with 44 additions and 1 deletions
+36 -1
View File
@@ -55,6 +55,9 @@ inline static void forward_msg(neu_manager_t *manager, nng_msg *msg,
const char *ndoe);
static void start_static_adapter(neu_manager_t *manager, const char *name);
static int report_nodes_state(void *usr_data);
static void start_system_adapter(neu_manager_t *manager, const char *name,
const char *plugin_lib,
const char *plugin_name);
neu_manager_t *neu_manager_create()
{
@@ -89,6 +92,8 @@ neu_manager_t *neu_manager_create()
manager->loop = neu_event_add_io(manager->events, param);
start_static_adapter(manager, DEFAULT_DASHBOARD_PLUGIN_NAME);
start_system_adapter(manager, LICENSE_SERVER_NODE_NAME, LICENSE_PLUGIN_LIB,
LICENSE_PLUGIN_NAME);
if (manager_load_plugin(manager) != 0) {
nlog_warn("load plugin error");
@@ -519,6 +524,36 @@ static void start_static_adapter(neu_manager_t *manager, const char *name)
neu_adapter_start(adapter);
}
static void start_system_adapter(neu_manager_t *manager, const char *name,
const char *plugin_lib,
const char *plugin_name)
{
neu_adapter_t * adapter = NULL;
neu_plugin_instance_t instance = { 0 };
neu_adapter_info_t adapter_info = {
.name = name,
};
if (0 != neu_manager_add_plugin(manager, plugin_lib)) {
return;
}
if (0 !=
neu_plugin_manager_create_instance(manager->plugin_manager, plugin_name,
&instance)) {
return;
}
adapter_info.handle = instance.handle;
adapter_info.module = instance.module;
adapter = neu_adapter_create(&adapter_info, true);
// add as static
neu_node_manager_add_static(manager->node_manager, adapter);
neu_adapter_init(adapter);
neu_adapter_start(adapter);
}
inline static void reply(neu_manager_t *manager, neu_reqresp_head_t *header,
void *data)
{
@@ -572,4 +607,4 @@ static int report_nodes_state(void *usr_data)
utarray_free(states);
return 0;
}
}
+2
View File
@@ -27,6 +27,8 @@
#include "adapter.h"
#define LICENSE_SERVER_NODE_NAME "neuron-license-server"
typedef struct neu_node_manager neu_node_manager_t;
neu_node_manager_t *neu_node_manager_create();
+4
View File
@@ -155,6 +155,10 @@ UT_array *neu_plugin_manager_get(neu_plugin_manager_t *mgr)
utarray_new(plugins, &icd);
HASH_ITER(hh, mgr->plugins, el, tmp)
{
if (0 == strcmp(LICENSE_PLUGIN_NAME, el->name)) {
continue;
}
neu_resp_plugin_info_t info = {
.kind = el->kind,
.type = el->type,
+2
View File
@@ -27,6 +27,8 @@
#include "plugin.h"
#define DEFAULT_DASHBOARD_PLUGIN_NAME "default-dashboard"
#define LICENSE_PLUGIN_LIB "libplugin-license-server.so"
#define LICENSE_PLUGIN_NAME "neuron-license-server"
typedef struct neu_plugin_instance {
void * handle;