mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2026-03-14 21:20:28 +01:00
Updated signal handler for microservices
This commit is contained in:
parent
7997de62b7
commit
62705f83d8
3 changed files with 23 additions and 18 deletions
|
|
@ -64,15 +64,6 @@ static void sig_handler(int sig)
|
|||
}
|
||||
}
|
||||
|
||||
static void service_sig_handler(int sig)
|
||||
{
|
||||
WARNING("# Micro-service PID[%ld] received %d signal ...", getpid(), sig);
|
||||
if (sig == SIGSEGV) {
|
||||
ERR("# Micro-service in PID[%ld] ...", getpid());
|
||||
}
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
static void signal_init(void)
|
||||
{
|
||||
signal(SIGSEGV, sig_handler);
|
||||
|
|
@ -81,7 +72,7 @@ static void signal_init(void)
|
|||
|
||||
static void service_signal_init(void)
|
||||
{
|
||||
signal(SIGSEGV, service_sig_handler);
|
||||
signal(SIGSEGV, sig_handler);
|
||||
}
|
||||
|
||||
static void usage(char *prog)
|
||||
|
|
@ -1693,10 +1684,9 @@ void bbfdm_ctx_init(struct bbfdm_context *bbfdm_ctx)
|
|||
int daemon_load_datamodel(struct bbfdm_context *daemon_ctx)
|
||||
{
|
||||
int err = -1;
|
||||
char *tmp = daemon_ctx->config.in_type;
|
||||
char *file_path = daemon_ctx->config.in_name;
|
||||
|
||||
if (DM_STRLEN(tmp) == 0 || DM_STRLEN(file_path) == 0) {
|
||||
if (DM_STRLEN(file_path) == 0) {
|
||||
ERR("Input type/name not supported or defined");
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -1723,12 +1713,17 @@ int daemon_load_datamodel(struct bbfdm_context *daemon_ctx)
|
|||
}
|
||||
}
|
||||
|
||||
if (strcasecmp(tmp, "JSON") == 0) {
|
||||
char *ext = strrchr(file_path, '.');
|
||||
if (ext == NULL) {
|
||||
ERR("Input file without extension");
|
||||
} else if (strcasecmp(ext, ".json") == 0) {
|
||||
ERR("Loading JSON plugin");
|
||||
err = load_json_plugin(&loaded_json_files, &json_list, &json_memhead, file_path, &DEAMON_DM_ROOT_OBJ);
|
||||
} else if (strcasecmp(tmp, "DotSo") == 0) {
|
||||
} else if (strcasecmp(ext, ".so") == 0) {
|
||||
ERR("Loading DotSo plugin");
|
||||
err = load_dotso_plugin(&deamon_lib_handle, file_path, &DEAMON_DM_ROOT_OBJ);
|
||||
} else {
|
||||
ERR("Input type %s not supported", tmp);
|
||||
ERR("Input type %s not supported", ext);
|
||||
}
|
||||
|
||||
if (!err) {
|
||||
|
|
|
|||
|
|
@ -55,6 +55,10 @@ int bbfdm_cmd_exec(struct dmctx *bbf_ctx, int cmd)
|
|||
} else {
|
||||
ERR("PID [%ld]::Exception on [%d => %s]", getpid(), cmd, bbf_ctx->in_param);
|
||||
fault = USP_FAULT_INTERNAL_ERROR;
|
||||
if (is_micro_service) {
|
||||
ERR("Micro-service PID [%ld]::Exception on [%d => %s]", getpid(), cmd, bbf_ctx->in_param);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
gs_jump_called_by_bbf = false;
|
||||
|
|
|
|||
|
|
@ -34,8 +34,10 @@ static uint8_t find_number_of_objects(DM_MAP_OBJ *dynamic_obj)
|
|||
|
||||
int load_dotso_plugin(void **lib_handle, const char *file_path, DMOBJ **main_entry)
|
||||
{
|
||||
if (!lib_handle || !file_path || !strlen(file_path) || !main_entry)
|
||||
if (!lib_handle || !file_path || !strlen(file_path) || !main_entry) {
|
||||
ERR("Input validation failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
void *handle = dlopen(file_path, RTLD_NOW|RTLD_LOCAL);
|
||||
if (!handle) {
|
||||
|
|
@ -105,12 +107,16 @@ int load_json_plugin(struct list_head *json_plugin, struct list_head *json_list,
|
|||
int json_plugin_version = JSON_VERSION_0;
|
||||
uint8_t idx = 0;
|
||||
|
||||
if (!file_path || !strlen(file_path) || !main_entry)
|
||||
if (!file_path || !strlen(file_path) || !main_entry) {
|
||||
ERR("Entry validation failed ...");
|
||||
return -1;
|
||||
}
|
||||
|
||||
json_object *json_obj = json_object_from_file(file_path);
|
||||
if (!json_obj)
|
||||
if (!json_obj) {
|
||||
ERR("Failed to parse json file (%s)", file_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
save_loaded_json_files(json_plugin, json_obj);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue