mirror of
https://github.com/emqx/neuron.git
synced 2026-10-29 23:19:18 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6af32bd9fc | ||
|
|
13becdd6af | ||
|
|
5c2ed5f1a3 | ||
|
|
a0bb29c100 | ||
|
|
fb6e92665a | ||
|
|
d7929b5553 | ||
|
|
a11d622fa6 | ||
|
|
c3ed9cc69d | ||
|
|
54dfc3709e | ||
|
|
253f254bd3 | ||
|
|
214c82b508 | ||
|
|
fdfc819c25 | ||
|
|
2ba608f9fe | ||
|
|
89069da064 | ||
|
|
aec03ecaf9 | ||
|
|
40fdc17b57 | ||
|
|
dda1007c50 | ||
|
|
da4295aec9 | ||
|
|
cfb3d073c5 |
@@ -8,8 +8,8 @@ on:
|
||||
- published
|
||||
|
||||
env:
|
||||
VERSION: 2.3.8
|
||||
UI_VERSION: 2.3.7
|
||||
VERSION: 2.3.10
|
||||
UI_VERSION: 2.3.9
|
||||
BRANCH: v2.3
|
||||
|
||||
jobs:
|
||||
|
||||
+6
-6
@@ -59,6 +59,9 @@ else()
|
||||
link_directories(/usr/local/lib)
|
||||
endif()
|
||||
|
||||
set(PERSIST_SOURCES
|
||||
src/persist/persist.c
|
||||
src/persist/json/persist_json_plugin.c)
|
||||
aux_source_directory(src/parser NEURON_SRC_PARSE)
|
||||
set(NEURON_BASE_SOURCES
|
||||
src/base/tag.c
|
||||
@@ -74,7 +77,8 @@ set(NEURON_BASE_SOURCES
|
||||
src/utils/neu_jwt.c
|
||||
src/utils/base64.c
|
||||
src/utils/async_queue.c
|
||||
src/utils/mem_cache.c)
|
||||
src/utils/mem_cache.c
|
||||
${PERSIST_SOURCES})
|
||||
|
||||
add_library(neuron-base SHARED)
|
||||
target_sources(neuron-base PRIVATE ${NEURON_BASE_SOURCES} ${NEURON_SRC_PARSE})
|
||||
@@ -89,9 +93,6 @@ add_dependencies(neuron-base neuron-version)
|
||||
#find_package(MbedTLS)
|
||||
target_link_libraries(neuron-base mbedtls mbedx509 mbedcrypto)
|
||||
|
||||
set(PERSIST_SOURCES
|
||||
src/persist/persist.c
|
||||
src/persist/json/persist_json_plugin.c)
|
||||
set(NEURON_SOURCES
|
||||
src/main.c
|
||||
src/argparse.c
|
||||
@@ -123,8 +124,7 @@ set(NEURON_SOURCES
|
||||
plugins/restful/proxy.c
|
||||
plugins/restful/websocket.c
|
||||
plugins/monitor/monitor.c
|
||||
plugins/monitor/metric_handle.c
|
||||
${PERSIST_SOURCES})
|
||||
plugins/monitor/metric_handle.c)
|
||||
|
||||
set(CMAKE_BUILD_RPATH ./)
|
||||
add_executable(neuron)
|
||||
|
||||
@@ -24,7 +24,9 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "adapter/adapter_info.h"
|
||||
#include <sqlite3.h>
|
||||
|
||||
#include "adapter_info.h"
|
||||
#include "persist/json/persist_json_plugin.h"
|
||||
|
||||
typedef neu_json_plugin_req_plugin_t neu_persist_plugin_info_t;
|
||||
@@ -84,12 +86,14 @@ static inline void neu_persist_user_info_fini(neu_persist_user_info_t *info)
|
||||
* Create persister.
|
||||
* @return 0 on success, -1 otherwise.
|
||||
*/
|
||||
int neu_persister_create();
|
||||
int neu_persister_create(const char *schema_dir);
|
||||
/**
|
||||
* Destroy perister.
|
||||
*/
|
||||
void neu_persister_destroy();
|
||||
|
||||
sqlite3 *neu_persister_get_db();
|
||||
|
||||
/**
|
||||
* Persist nodes.
|
||||
* @param node_info neu_persist_node_info_t.
|
||||
@@ -306,4 +310,4 @@ int neu_persister_delete_user(const char *user_name);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -50,11 +50,9 @@ static int http_resp_files(nng_aio *aio, void *data, size_t len,
|
||||
|
||||
void handle_logs_files(nng_aio *aio)
|
||||
{
|
||||
char path[128] = { 0 };
|
||||
char disp[128] = { 0 };
|
||||
void * data = NULL;
|
||||
size_t len = 0;
|
||||
int rv = 0;
|
||||
void * data = NULL;
|
||||
size_t len = 0;
|
||||
int rv = 0;
|
||||
|
||||
VALIDATE_JWT(aio);
|
||||
|
||||
@@ -68,18 +66,37 @@ void handle_logs_files(nng_aio *aio)
|
||||
return;
|
||||
}
|
||||
|
||||
rv = system("rm -rf /tmp/neuron_debug.tar.gz");
|
||||
nlog_warn("remove old neuron_debug.tar.gz, rv: %d", rv);
|
||||
/* tar the neuron directory */
|
||||
rv = system("tar -zcvf neuron_debug.tar.gz ../neuron");
|
||||
if (0 != rv) {
|
||||
nlog_error("failed to create neuron_debug.tar.gz");
|
||||
rv = system("tar -zcvf /tmp/neuron_debug.tar.gz ../neuron");
|
||||
if (rv == -1) {
|
||||
nlog_error("failed to create neuron_debug.tar.gz, rv: %d", rv);
|
||||
NEU_JSON_RESPONSE_ERROR(NEU_ERR_COMMAND_EXECUTION_FAILED, {
|
||||
http_response(aio, error_code.error, result_error);
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
if (WIFEXITED(rv)) {
|
||||
if (WEXITSTATUS(rv) != 0) {
|
||||
nlog_error("failed to create neuron_debug.tar.gz, rv: %d",
|
||||
WEXITSTATUS(rv));
|
||||
NEU_JSON_RESPONSE_ERROR(NEU_ERR_COMMAND_EXECUTION_FAILED, {
|
||||
http_response(aio, error_code.error, result_error);
|
||||
});
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
nlog_error("failed to create neuron_debug.tar.gz, rv: %d",
|
||||
WEXITSTATUS(rv));
|
||||
NEU_JSON_RESPONSE_ERROR(NEU_ERR_COMMAND_EXECUTION_FAILED, {
|
||||
http_response(aio, error_code.error, result_error);
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
strcpy(path, "neuron_debug.tar.gz");
|
||||
rv = read_file(path, &data, &len);
|
||||
rv = read_file("/tmp/neuron_debug.tar.gz", &data, &len);
|
||||
if (0 != rv) {
|
||||
NEU_JSON_RESPONSE_ERROR(
|
||||
rv, { http_response(aio, error_code.error, result_error); });
|
||||
@@ -87,11 +104,10 @@ void handle_logs_files(nng_aio *aio)
|
||||
}
|
||||
|
||||
/* handle http response */
|
||||
strcpy(disp, "attachment; filename=neuron_debug.tar.gz");
|
||||
rv = http_resp_files(aio, data, len, disp);
|
||||
if (0 != rv) {
|
||||
return;
|
||||
}
|
||||
rv = http_resp_files(aio, data, len,
|
||||
"attachment; filename=neuron_debug.tar.gz");
|
||||
|
||||
nlog_notice("download neuron_debug.tar.gz, ret: %d", rv);
|
||||
}
|
||||
|
||||
void handle_log_level(nng_aio *aio)
|
||||
|
||||
+1
-1
@@ -94,7 +94,7 @@ static inline int reset_password()
|
||||
"$5$PwFeXpBBIBZuZdZl$fP8fFPWCLoaWcnVXVSR.3Xi8TEqCvX92gjhowNNn6S4",
|
||||
};
|
||||
|
||||
int rv = neu_persister_create();
|
||||
int rv = neu_persister_create(g_config_dir);
|
||||
if (0 != rv) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
+2
-3
@@ -42,13 +42,12 @@ static void sig_handler(int sig)
|
||||
{
|
||||
nlog_warn("recv sig: %d", sig);
|
||||
|
||||
if (sig != SIGABRT) {
|
||||
if (sig == SIGINT || sig == SIGTERM) {
|
||||
neu_manager_destroy(g_manager);
|
||||
neu_persister_destroy();
|
||||
}
|
||||
zlog_fini();
|
||||
exit_flag = true;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
static int neuron_run(const neu_cli_args_t *args)
|
||||
@@ -67,7 +66,7 @@ static int neuron_run(const neu_cli_args_t *args)
|
||||
nlog_warn("neuron process failed enable core dump, ignore");
|
||||
}
|
||||
|
||||
rv = neu_persister_create();
|
||||
rv = neu_persister_create(args->config_dir);
|
||||
assert(rv == 0);
|
||||
|
||||
zlog_notice(neuron, "neuron process, daemon: %d, version: %s (%s %s)",
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
#include "json/json.h"
|
||||
|
||||
#include "persist_json_plugin.h"
|
||||
#include "persist/json/persist_json_plugin.h"
|
||||
|
||||
int neu_json_decode_plugin_req(char *buf, neu_json_plugin_req_t **result)
|
||||
{
|
||||
|
||||
@@ -430,7 +430,7 @@ static int apply_schemas(sqlite3 *db, const char *dir)
|
||||
return rv;
|
||||
}
|
||||
|
||||
int neu_persister_create()
|
||||
int neu_persister_create(const char *schema_dir)
|
||||
{
|
||||
int rv = sqlite3_open(db_file, &global_db);
|
||||
|
||||
@@ -455,7 +455,7 @@ int neu_persister_create()
|
||||
return -1;
|
||||
}
|
||||
|
||||
rv = apply_schemas(global_db, g_config_dir);
|
||||
rv = apply_schemas(global_db, schema_dir);
|
||||
if (rv != 0) {
|
||||
nlog_fatal("db apply schemas fail");
|
||||
sqlite3_close(global_db);
|
||||
@@ -465,6 +465,11 @@ int neu_persister_create()
|
||||
return 0;
|
||||
}
|
||||
|
||||
sqlite3 *neu_persister_get_db()
|
||||
{
|
||||
return global_db;
|
||||
}
|
||||
|
||||
void neu_persister_destroy()
|
||||
{
|
||||
sqlite3_close(global_db);
|
||||
|
||||
Reference in New Issue
Block a user