mirror of
https://github.com/emqx/neuron.git
synced 2026-10-18 21:50:42 +08:00
Merge pull request #1126 from eeff/eeff/2.3
Pick to v2.3: move persister to neuron base
This commit is contained in:
+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)
|
||||
|
||||
@@ -84,7 +84,7 @@ 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.
|
||||
*/
|
||||
@@ -306,4 +306,4 @@ int neu_persister_delete_user(const char *user_name);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
+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;
|
||||
}
|
||||
|
||||
+1
-1
@@ -66,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);
|
||||
|
||||
Reference in New Issue
Block a user