Compare commits
10 Commits
58e51f6b14
...
b8f065d1e8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8f065d1e8 | ||
|
|
d4398f6f54 | ||
|
|
76de16a51e | ||
|
|
03dc71ac73 | ||
|
|
1f4e1719e5 | ||
|
|
43ee2f3faf | ||
|
|
0fef201ac5 | ||
|
|
d3dc2ec15e | ||
|
|
90f1b4bfec | ||
|
|
090cfe6c51 |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,30 @@
|
||||
From 54c5b50eb19467d32d83a85478f468dff52b69e6 Mon Sep 17 00:00:00 2001
|
||||
From: Zhao Mengmeng <zhaomengmeng@kylinos.cn>
|
||||
Date: Thu, 27 Jun 2024 13:45:00 +0800
|
||||
Subject: [PATCH 1/4] plugin_mgr: logger: apppend to logfile rather than
|
||||
truncate
|
||||
|
||||
In log4cplus, the default openmode for Class FileAppender is
|
||||
std::ios_base::trunc, which cause the log file be cleared after
|
||||
each `systemctl restart oeaware.service`. Fix this by setting
|
||||
openmode to std::ios_base::app.
|
||||
---
|
||||
src/plugin_mgr/logger.cpp | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/plugin_mgr/logger.cpp b/src/plugin_mgr/logger.cpp
|
||||
index af39583..378075c 100644
|
||||
--- a/src/plugin_mgr/logger.cpp
|
||||
+++ b/src/plugin_mgr/logger.cpp
|
||||
@@ -27,7 +27,7 @@ Logger::Logger() {
|
||||
}
|
||||
|
||||
void Logger::init(std::shared_ptr<Config> config) {
|
||||
- log4cplus::SharedAppenderPtr appender(new log4cplus::FileAppender(config->get_log_path() + "/server.log"));
|
||||
+ log4cplus::SharedAppenderPtr appender(new log4cplus::FileAppender(config->get_log_path() + "/server.log", std::ios_base::app));
|
||||
appender->setName("file");
|
||||
log4cplus::tstring pattern = LOG4CPLUS_TEXT("%D{%m/%d/%y %H:%M:%S} [%t] %-5p %c - %m"
|
||||
#ifdef OEAWARE_DEBUG
|
||||
--
|
||||
2.33.0
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,26 @@
|
||||
From ed8c8d44f05f7fd2160252cbe1b2d10cbd6000cf Mon Sep 17 00:00:00 2001
|
||||
From: zhoukaiqi <zhoukaiqi@huawei.com>
|
||||
Date: Sat, 6 Jul 2024 14:34:24 +0800
|
||||
Subject: [PATCH 3/4] fix threads are still bound after systemctl stop oeaware
|
||||
|
||||
---
|
||||
src/plugin_mgr/main.cpp | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/plugin_mgr/main.cpp b/src/plugin_mgr/main.cpp
|
||||
index 5cfb020..9add8ac 100644
|
||||
--- a/src/plugin_mgr/main.cpp
|
||||
+++ b/src/plugin_mgr/main.cpp
|
||||
@@ -39,7 +39,8 @@ void signal_handler(int signum) {
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
- signal(SIGINT, signal_handler);
|
||||
+ signal(SIGINT, signal_handler); // ctrl + c
|
||||
+ signal(SIGTERM, signal_handler); // systemctl stop
|
||||
std::shared_ptr<Config> config = std::make_shared<Config>();
|
||||
if (argc < 2) {
|
||||
ERROR("System need a argument!");
|
||||
--
|
||||
2.33.0
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
175
0003-fix-coredump-when-process-exits.patch
Normal file
175
0003-fix-coredump-when-process-exits.patch
Normal file
@ -0,0 +1,175 @@
|
||||
From d6d5fe30da78917f3d32e670b79a8603ace76af4 Mon Sep 17 00:00:00 2001
|
||||
From: fly_1997 <flylove7@outlook.com>
|
||||
Date: Mon, 8 Jul 2024 16:53:18 +0800
|
||||
Subject: [PATCH 4/4] fix coredump when process exits
|
||||
|
||||
---
|
||||
src/plugin_mgr/instance_run_handler.cpp | 18 +++++++++++++++---
|
||||
src/plugin_mgr/instance_run_handler.h | 3 ++-
|
||||
src/plugin_mgr/main.cpp | 18 +++++-------------
|
||||
src/plugin_mgr/plugin_manager.cpp | 18 ++++++++++++++++++
|
||||
src/plugin_mgr/plugin_manager.h | 7 +++++++
|
||||
5 files changed, 47 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/src/plugin_mgr/instance_run_handler.cpp b/src/plugin_mgr/instance_run_handler.cpp
|
||||
index 7f03f8f..70e3c33 100644
|
||||
--- a/src/plugin_mgr/instance_run_handler.cpp
|
||||
+++ b/src/plugin_mgr/instance_run_handler.cpp
|
||||
@@ -107,8 +107,9 @@ void InstanceRunHandler::disable_instance(const std::string &name, bool force) {
|
||||
}
|
||||
}
|
||||
|
||||
-void InstanceRunHandler::handle_instance() {
|
||||
+bool InstanceRunHandler::handle_message() {
|
||||
std::shared_ptr<InstanceRunMessage> msg;
|
||||
+ bool shutdown = false;
|
||||
while(this->recv_queue_try_pop(msg)){
|
||||
std::shared_ptr<Instance> instance = msg->get_instance();
|
||||
switch (msg->get_type()){
|
||||
@@ -120,9 +121,17 @@ void InstanceRunHandler::handle_instance() {
|
||||
disable_instance(instance->get_name(), true);
|
||||
break;
|
||||
}
|
||||
+ case RunType::SHUTDOWN: {
|
||||
+ shutdown = true;
|
||||
+ break;
|
||||
+ }
|
||||
}
|
||||
msg->notify_one();
|
||||
+ if (shutdown) {
|
||||
+ return false;
|
||||
+ }
|
||||
}
|
||||
+ return true;
|
||||
}
|
||||
|
||||
void InstanceRunHandler::change_instance_state(const std::string &name, std::vector<std::string> &deps,
|
||||
@@ -183,9 +192,12 @@ void InstanceRunHandler::schedule() {
|
||||
}
|
||||
|
||||
void start(InstanceRunHandler *instance_run_handler) {
|
||||
- INFO("[PluginManager] instance schedule started!");
|
||||
+ INFO("[InstanceRunHandler] instance schedule started!");
|
||||
while(true) {
|
||||
- instance_run_handler->handle_instance();
|
||||
+ if (!instance_run_handler->handle_message()) {
|
||||
+ INFO("[InstanceRunHandler] instance schedule shutdown!");
|
||||
+ break;
|
||||
+ }
|
||||
instance_run_handler->schedule();
|
||||
usleep(instance_run_handler->get_cycle() * 1000);
|
||||
instance_run_handler->add_time(instance_run_handler->get_cycle());
|
||||
diff --git a/src/plugin_mgr/instance_run_handler.h b/src/plugin_mgr/instance_run_handler.h
|
||||
index 64ddfa5..90cc60e 100644
|
||||
--- a/src/plugin_mgr/instance_run_handler.h
|
||||
+++ b/src/plugin_mgr/instance_run_handler.h
|
||||
@@ -22,6 +22,7 @@ enum class RunType {
|
||||
/* Message from PluginManager. */
|
||||
ENABLED,
|
||||
DISABLED,
|
||||
+ SHUTDOWN,
|
||||
};
|
||||
|
||||
/* Message for communication between plugin manager and instance scheduling */
|
||||
@@ -70,7 +71,7 @@ public:
|
||||
explicit InstanceRunHandler(MemoryStore &memory_store) : memory_store(memory_store), time(0), cycle(DEFAULT_CYCLE_SIZE) { }
|
||||
void run();
|
||||
void schedule();
|
||||
- void handle_instance();
|
||||
+ bool handle_message();
|
||||
void set_cycle(int cycle) {
|
||||
this->cycle = cycle;
|
||||
}
|
||||
diff --git a/src/plugin_mgr/main.cpp b/src/plugin_mgr/main.cpp
|
||||
index 9add8ac..626aea9 100644
|
||||
--- a/src/plugin_mgr/main.cpp
|
||||
+++ b/src/plugin_mgr/main.cpp
|
||||
@@ -22,20 +22,12 @@ void print_help() {
|
||||
}
|
||||
|
||||
void signal_handler(int signum) {
|
||||
- auto &plugin_manager = PluginManager::get_instance();
|
||||
- auto memory_store = plugin_manager.get_memory_store();
|
||||
- auto all_plugins = memory_store.get_all_plugins();
|
||||
- for (auto plugin : all_plugins) {
|
||||
- for (size_t i = 0; i < plugin->get_instance_len(); ++i) {
|
||||
- auto instance = plugin->get_instance(i);
|
||||
- if (!instance->get_enabled()) {
|
||||
- continue;
|
||||
- }
|
||||
- instance->get_interface()->disable();
|
||||
- INFO("[PluginManager] " << instance->get_name() << " instance disabled.");
|
||||
- }
|
||||
+ if (signum != SIGINT && signum != SIGTERM) {
|
||||
+ ERROR("Unknown signal: " << signum);
|
||||
+ exit(signum);
|
||||
}
|
||||
- exit(signum);
|
||||
+ auto &plugin_manager = PluginManager::get_instance();
|
||||
+ plugin_manager.send_msg(Message(Opt::SHUTDOWN, MessageType::INTERNAL));
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
diff --git a/src/plugin_mgr/plugin_manager.cpp b/src/plugin_mgr/plugin_manager.cpp
|
||||
index c3ff8bf..b979859 100644
|
||||
--- a/src/plugin_mgr/plugin_manager.cpp
|
||||
+++ b/src/plugin_mgr/plugin_manager.cpp
|
||||
@@ -336,6 +336,23 @@ void PluginManager::pre_load() {
|
||||
pre_enable();
|
||||
}
|
||||
|
||||
+void PluginManager::exit() {
|
||||
+ auto all_plugins = memory_store.get_all_plugins();
|
||||
+ auto msg = std::make_shared<InstanceRunMessage>(RunType::SHUTDOWN, nullptr);
|
||||
+ send_msg_to_instance_run_handler(msg);
|
||||
+ msg->wait();
|
||||
+ for (auto plugin : all_plugins) {
|
||||
+ for (size_t i = 0; i < plugin->get_instance_len(); ++i) {
|
||||
+ auto instance = plugin->get_instance(i);
|
||||
+ if (!instance->get_enabled()) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ instance->get_interface()->disable();
|
||||
+ INFO("[PluginManager] " << instance->get_name() << " instance disabled.");
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
const void* PluginManager::get_data_buffer(const std::string &name) {
|
||||
std::shared_ptr<Instance> instance = memory_store.get_instance(name);
|
||||
return instance->get_interface()->get_ring_buf();
|
||||
@@ -553,5 +570,6 @@ int PluginManager::run() {
|
||||
if (msg.get_type() == MessageType::EXTERNAL)
|
||||
res_msg->push(res);
|
||||
}
|
||||
+ exit();
|
||||
return 0;
|
||||
}
|
||||
diff --git a/src/plugin_mgr/plugin_manager.h b/src/plugin_mgr/plugin_manager.h
|
||||
index b7c04fe..c3f6f69 100644
|
||||
--- a/src/plugin_mgr/plugin_manager.h
|
||||
+++ b/src/plugin_mgr/plugin_manager.h
|
||||
@@ -32,6 +32,10 @@ public:
|
||||
const MemoryStore& get_memory_store() {
|
||||
return this->memory_store;
|
||||
}
|
||||
+ void exit();
|
||||
+ void send_msg(const Message &msg) {
|
||||
+ handler_msg->push(msg);
|
||||
+ }
|
||||
const void* get_data_buffer(const std::string &name);
|
||||
private:
|
||||
PluginManager() { }
|
||||
@@ -57,6 +61,9 @@ private:
|
||||
void update_instance_state();
|
||||
bool end_with(const std::string &s, const std::string &ending);
|
||||
std::string get_plugin_in_dir(const std::string &path);
|
||||
+ void send_msg_to_instance_run_handler(std::shared_ptr<InstanceRunMessage> msg) {
|
||||
+ instance_run_handler->recv_queue_push(msg);
|
||||
+ }
|
||||
private:
|
||||
std::unique_ptr<InstanceRunHandler> instance_run_handler;
|
||||
std::shared_ptr<Config> config;
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -1,200 +0,0 @@
|
||||
From 7ff05329ac299727fc2be5d7f1a92a4e3b0bdd43 Mon Sep 17 00:00:00 2001
|
||||
From: fly_1997 <flylove7@outlook.com>
|
||||
Date: Mon, 29 Apr 2024 17:31:44 +0800
|
||||
Subject: [PATCH 4/4] fix auto enable error and check plugin list config
|
||||
|
||||
---
|
||||
oeaware.service | 2 +-
|
||||
src/client/arg_parse.cpp | 7 ++++---
|
||||
src/common/utils.cpp | 34 ++++++++++++++++++-------------
|
||||
src/plugin_mgr/config.cpp | 21 ++++++++++++++-----
|
||||
src/plugin_mgr/config.h | 3 +++
|
||||
src/plugin_mgr/plugin_manager.cpp | 11 +++++++++-
|
||||
6 files changed, 54 insertions(+), 24 deletions(-)
|
||||
|
||||
diff --git a/oeaware.service b/oeaware.service
|
||||
index 3ab4b69..b321530 100644
|
||||
--- a/oeaware.service
|
||||
+++ b/oeaware.service
|
||||
@@ -5,7 +5,7 @@ After=network.target
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/oeaware /etc/oeAware/config.yaml
|
||||
-ExecStop=kill -9 $MAINPID
|
||||
+ExecStop=kill $MAINPID && sleep 5 && kill -9 $MAINPID
|
||||
Restart=on-failure
|
||||
RestartSec=1
|
||||
RemainAfterExit=yes
|
||||
diff --git a/src/client/arg_parse.cpp b/src/client/arg_parse.cpp
|
||||
index cbf0b8e..70fcd4a 100644
|
||||
--- a/src/client/arg_parse.cpp
|
||||
+++ b/src/client/arg_parse.cpp
|
||||
@@ -30,6 +30,7 @@ const struct option ArgParse::long_options[] = {
|
||||
|
||||
void ArgParse::arg_error(const std::string &msg) {
|
||||
std::cerr << "oeawarectl: " << msg << "\n";
|
||||
+ print_help();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -42,7 +43,7 @@ void ArgParse::set_arg(char *_arg) {
|
||||
}
|
||||
|
||||
void ArgParse::print_help() {
|
||||
- std::cout << "oeawarectl [options]...\n"
|
||||
+ std::cout << "usage: oeawarectl [options]...\n"
|
||||
" options\n"
|
||||
" -l|--load [plugin] load plugin and need plugin type.\n"
|
||||
" -t|--type [plugin_type] assign plugin type. there are three types:\n"
|
||||
@@ -76,12 +77,12 @@ int ArgParse::init(int argc, char *argv[]) {
|
||||
help = true;
|
||||
break;
|
||||
case '?':
|
||||
- arg_error("unknown option. See --help.");
|
||||
+ arg_error("unknown option.");
|
||||
return -1;
|
||||
default: {
|
||||
if (opt == 'l' || opt == 'r' || opt == 'q' || opt == 'Q' || opt == 'e' || opt == 'd' || opt == 'L' || opt == 'i') {
|
||||
if (cmd != -1) {
|
||||
- arg_error("invalid option. See --help.\n");
|
||||
+ arg_error("invalid option.");
|
||||
return -1;
|
||||
}
|
||||
cmd = opt;
|
||||
diff --git a/src/common/utils.cpp b/src/common/utils.cpp
|
||||
index 9435a5b..f2c277d 100644
|
||||
--- a/src/common/utils.cpp
|
||||
+++ b/src/common/utils.cpp
|
||||
@@ -23,28 +23,34 @@ static void curl_set_opt(CURL *curl, const std::string &url, FILE *file) {
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, file);
|
||||
|
||||
}
|
||||
+static bool curl_handle(CURL *curl, const std::string &url, const std::string &path) {
|
||||
+ FILE *file = fopen(path.c_str(), "wb");
|
||||
+ if (file == nullptr) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ curl_set_opt(curl, url, file);
|
||||
+ CURLcode res = curl_easy_perform(curl);
|
||||
+ long http_code = 0;
|
||||
+ curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_code);
|
||||
+ fclose(file);
|
||||
+ if (res == CURLE_OK && http_code >= 200 && http_code < 300) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
// Downloads file from the specified url to the path.
|
||||
bool download(const std::string &url, const std::string &path) {
|
||||
CURL *curl = nullptr;
|
||||
- CURLcode res;
|
||||
- bool ok = true;
|
||||
+ bool ret = true;
|
||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||
curl = curl_easy_init();
|
||||
if (curl) {
|
||||
- FILE *file = fopen(path.c_str(), "wb");
|
||||
- if (file == nullptr) {
|
||||
- return false;
|
||||
- }
|
||||
- curl_set_opt(curl, url, file);
|
||||
- res = curl_easy_perform(curl);
|
||||
- fclose(file);
|
||||
- if (res != CURLE_OK) {
|
||||
- ok = false;
|
||||
- }
|
||||
+ if (!curl_handle(curl, url, path)) ret = false;
|
||||
} else {
|
||||
- ok = false;
|
||||
+ ret = false;
|
||||
}
|
||||
curl_global_cleanup();
|
||||
curl_easy_cleanup(curl);
|
||||
- return ok;
|
||||
+ return ret;
|
||||
}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/plugin_mgr/config.cpp b/src/plugin_mgr/config.cpp
|
||||
index 1de5a34..3c76e8e 100644
|
||||
--- a/src/plugin_mgr/config.cpp
|
||||
+++ b/src/plugin_mgr/config.cpp
|
||||
@@ -30,6 +30,18 @@ bool create_dir(const std::string &path) {
|
||||
return true;
|
||||
}
|
||||
|
||||
+bool check_plugin_list(YAML::Node plugin_list_item) {
|
||||
+ if (plugin_list_item["name"].IsNull()) {
|
||||
+ std::cerr << "Warn: null name in plugin_list.\n";
|
||||
+ return false;
|
||||
+ }
|
||||
+ if (plugin_list_item["url"].IsNull()) {
|
||||
+ std::cerr << "Warn: null url in plugin_list.\n";
|
||||
+ return false;
|
||||
+ }
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
bool Config::load(const std::string path) {
|
||||
YAML::Node node;
|
||||
struct stat buffer;
|
||||
@@ -49,16 +61,15 @@ bool Config::load(const std::string path) {
|
||||
YAML::Node plugin_list = node["plugin_list"];
|
||||
if (plugin_list.IsSequence()) {
|
||||
for (int i = 0; i < plugin_list.size(); ++i) {
|
||||
+ if (!check_plugin_list(plugin_list[i])){
|
||||
+ continue;
|
||||
+ }
|
||||
std::string name = plugin_list[i]["name"].as<std::string>();
|
||||
std::string description = plugin_list[i]["description"].as<std::string>();
|
||||
std::string url = plugin_list[i]["url"].as<std::string>();
|
||||
PluginInfo info(name, description, url);
|
||||
- if (name.empty()) {
|
||||
- std::cerr << "Warn: " << name << " url is empty.\n";
|
||||
- continue;
|
||||
- }
|
||||
if (this->plugin_list.count(name)) {
|
||||
- std::cerr << "Warn: duplicate " << name << " in plugin_list.\n";
|
||||
+ std::cerr << "Warn: duplicate \"" << name << "\" in plugin_list.\n";
|
||||
continue;
|
||||
}
|
||||
this->plugin_list.insert(std::make_pair(name, info));
|
||||
diff --git a/src/plugin_mgr/config.h b/src/plugin_mgr/config.h
|
||||
index 16c7871..5ab7672 100644
|
||||
--- a/src/plugin_mgr/config.h
|
||||
+++ b/src/plugin_mgr/config.h
|
||||
@@ -65,6 +65,9 @@ public:
|
||||
size_t get_instance_size() const {
|
||||
return this->instance.size();
|
||||
}
|
||||
+ std::string get_instance_name(int i) {
|
||||
+ return this->instance[i];
|
||||
+ }
|
||||
std::string get_name() const {
|
||||
return this->name;
|
||||
}
|
||||
diff --git a/src/plugin_mgr/plugin_manager.cpp b/src/plugin_mgr/plugin_manager.cpp
|
||||
index c9981ef..0826a60 100644
|
||||
--- a/src/plugin_mgr/plugin_manager.cpp
|
||||
+++ b/src/plugin_mgr/plugin_manager.cpp
|
||||
@@ -348,7 +348,16 @@ void PluginManager::pre_enable() {
|
||||
}
|
||||
std::shared_ptr<Plugin> plugin = memory_store.get_plugin(name);
|
||||
for (int j = 0; j < plugin->get_instance_len(); ++j) {
|
||||
- instance_enabled(plugin->get_instance(i)->get_name());
|
||||
+ instance_enabled(plugin->get_instance(j)->get_name());
|
||||
+ }
|
||||
+ } else {
|
||||
+ for (int j = 0; j < item.get_instance_size(); ++j) {
|
||||
+ std::string name = item.get_instance_name(j);
|
||||
+ if (!memory_store.is_instance_exist(name)) {
|
||||
+ WARN("[PluginManager] instance " << name << " cannot be enabled, because it does not exist.");
|
||||
+ continue;
|
||||
+ }
|
||||
+ instance_enabled(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -1,322 +0,0 @@
|
||||
From 906d417f7a370b6b9f60069bae41ee6d00d7537e Mon Sep 17 00:00:00 2001
|
||||
From: fly_1997 <flylove7@outlook.com>
|
||||
Date: Tue, 7 May 2024 18:02:15 +0800
|
||||
Subject: [PATCH] modify logs, sock file permission and fix service file,
|
||||
repetition of dependencies
|
||||
|
||||
---
|
||||
config.yaml | 11 ++++-----
|
||||
oeaware.service | 2 +-
|
||||
src/client/cmd_handler.cpp | 22 +++++++++++++-----
|
||||
src/client/cmd_handler.h | 2 ++
|
||||
src/plugin_mgr/dep_handler.cpp | 36 +++++++++++++++++++++---------
|
||||
src/plugin_mgr/dep_handler.h | 8 +++----
|
||||
src/plugin_mgr/error_code.cpp | 2 +-
|
||||
src/plugin_mgr/message_manager.cpp | 3 +++
|
||||
src/plugin_mgr/plugin.h | 6 +++--
|
||||
src/plugin_mgr/plugin_manager.cpp | 15 ++++++++-----
|
||||
10 files changed, 73 insertions(+), 34 deletions(-)
|
||||
|
||||
diff --git a/config.yaml b/config.yaml
|
||||
index ef0b44b..99d01d7 100644
|
||||
--- a/config.yaml
|
||||
+++ b/config.yaml
|
||||
@@ -1,8 +1,9 @@
|
||||
log_path: /var/log/oeAware
|
||||
-log_level: 1
|
||||
+log_level: 2
|
||||
enable_list:
|
||||
- - name: aaa.so
|
||||
+
|
||||
plugin_list:
|
||||
- - name: test
|
||||
- description: hello world
|
||||
- url: https://gitee.com/openeuler/oeAware-manager
|
||||
\ No newline at end of file
|
||||
+ - name: numafast
|
||||
+ description: numafast is a userspace tool designed for Kunpeng Chips that aims to improve
|
||||
+ system performance by reducing cross-NUMA memory access.
|
||||
+ url: https://repo.oepkgs.net/openeuler/rpm/openEuler-22.03-LTS-SP1/extras/aarch64/Packages/n/numafast-v1.0.0-2.aarch64.rpm
|
||||
\ No newline at end of file
|
||||
diff --git a/oeaware.service b/oeaware.service
|
||||
index b321530..be13c4b 100644
|
||||
--- a/oeaware.service
|
||||
+++ b/oeaware.service
|
||||
@@ -5,7 +5,7 @@ After=network.target
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/oeaware /etc/oeAware/config.yaml
|
||||
-ExecStop=kill $MAINPID && sleep 5 && kill -9 $MAINPID
|
||||
+ExecStop=kill $MAINPID
|
||||
Restart=on-failure
|
||||
RestartSec=1
|
||||
RemainAfterExit=yes
|
||||
diff --git a/src/client/cmd_handler.cpp b/src/client/cmd_handler.cpp
|
||||
index 1f2b8a5..4fec95b 100644
|
||||
--- a/src/client/cmd_handler.cpp
|
||||
+++ b/src/client/cmd_handler.cpp
|
||||
@@ -15,12 +15,22 @@
|
||||
|
||||
std::unordered_set<std::string> LoadHandler::types = {"collector", "scenario", "tune"};
|
||||
|
||||
+void LoadHandler::check(const std::string &arg, const std::string &type) {
|
||||
+ if (arg.empty()) {
|
||||
+ ArgParse::arg_error("plugin name empty.");
|
||||
+ }
|
||||
+ if (type.empty()) {
|
||||
+ ArgParse::arg_error("type empty.");
|
||||
+ }
|
||||
+ if (!types.count(type)) {
|
||||
+ ArgParse::arg_error("this type is not supported.");
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void LoadHandler::handler(const ArgParse &arg_parse, Msg &msg) {
|
||||
std::string arg = arg_parse.get_arg();
|
||||
std::string type = arg_parse.get_type();
|
||||
- if (arg.empty() || type.empty() || !types.count(type)) {
|
||||
- ArgParse::arg_error("args error.");
|
||||
- }
|
||||
+ check(arg, type);
|
||||
msg.add_payload(arg);
|
||||
msg.add_payload(type);
|
||||
msg.set_opt(Opt::LOAD);
|
||||
@@ -84,7 +94,7 @@ void RemoveHandler::handler(const ArgParse &arg_parse, Msg &msg) {
|
||||
|
||||
void RemoveHandler::res_handler(Msg &msg) {
|
||||
if (msg.get_opt() == Opt::RESPONSE_OK) {
|
||||
- std::cout << "plugin remove successful.\n";
|
||||
+ std::cout << "plugin remove successfully.\n";
|
||||
} else {
|
||||
std::cout << "plugin remove failed, because " << msg.payload(0) << ".\n";
|
||||
}
|
||||
@@ -131,7 +141,7 @@ void EnabledHandler::handler(const ArgParse &arg_parse, Msg &msg) {
|
||||
|
||||
void EnabledHandler::res_handler(Msg &msg) {
|
||||
if (msg.get_opt() == Opt::RESPONSE_OK) {
|
||||
- std::cout << "instance enabled.\n";
|
||||
+ std::cout << "instance enabled successfully.\n";
|
||||
} else {
|
||||
std::cout << "instance enabled failed, because "<< msg.payload(0) << ".\n";
|
||||
}
|
||||
@@ -145,7 +155,7 @@ void DisabledHandler::handler(const ArgParse &arg_parse, Msg &msg) {
|
||||
|
||||
void DisabledHandler::res_handler(Msg &msg) {
|
||||
if (msg.get_opt() == Opt::RESPONSE_OK) {
|
||||
- std::cout << "instance disabled.\n";
|
||||
+ std::cout << "instance disabled successfully.\n";
|
||||
} else {
|
||||
std::cout << "instance disabled failed, because "<< msg.payload(0) << ".\n";
|
||||
}
|
||||
diff --git a/src/client/cmd_handler.h b/src/client/cmd_handler.h
|
||||
index ab21944..1b6f1c1 100644
|
||||
--- a/src/client/cmd_handler.h
|
||||
+++ b/src/client/cmd_handler.h
|
||||
@@ -29,6 +29,7 @@ public:
|
||||
void handler(const ArgParse &arg_parse, Msg &msg) override;
|
||||
void res_handler(Msg &msg) override;
|
||||
private:
|
||||
+ void check(const std::string &arg, const std::string &type);
|
||||
static std::unordered_set<std::string> types;
|
||||
};
|
||||
|
||||
@@ -36,6 +37,7 @@ class QueryHandler : public CmdHandler {
|
||||
public:
|
||||
void handler(const ArgParse &arg_parse, Msg &msg) override;
|
||||
void res_handler(Msg &msg) override;
|
||||
+private:
|
||||
void print_format();
|
||||
};
|
||||
|
||||
diff --git a/src/plugin_mgr/dep_handler.cpp b/src/plugin_mgr/dep_handler.cpp
|
||||
index eff333c..652fdce 100644
|
||||
--- a/src/plugin_mgr/dep_handler.cpp
|
||||
+++ b/src/plugin_mgr/dep_handler.cpp
|
||||
@@ -11,6 +11,7 @@
|
||||
******************************************************************************/
|
||||
#include "dep_handler.h"
|
||||
#include <queue>
|
||||
+#include <unordered_set>
|
||||
#include <stdio.h>
|
||||
|
||||
void DepHandler::add_arc_node(std::shared_ptr<Node> node, const std::vector<std::string> &dep_nodes) {
|
||||
@@ -38,14 +39,14 @@ void DepHandler::add_arc_node(std::shared_ptr<Node> node, const std::vector<std:
|
||||
}
|
||||
|
||||
|
||||
-void DepHandler::add_node(std::string name, std::vector<std::string> dep_nodes) {
|
||||
+void DepHandler::add_node(const std::string &name, std::vector<std::string> dep_nodes) {
|
||||
std::shared_ptr<Node> cur_node = add_new_node(name);
|
||||
this->nodes[name] = cur_node;
|
||||
add_arc_node(cur_node, dep_nodes);
|
||||
change_arc_nodes(name, true);
|
||||
}
|
||||
|
||||
-void DepHandler::del_node(std::string name) {
|
||||
+void DepHandler::del_node(const std::string &name) {
|
||||
del_node_and_arc_nodes(get_node(name));
|
||||
this->nodes.erase(name);
|
||||
}
|
||||
@@ -119,26 +120,41 @@ void DepHandler::query_node_top(std::string name, std::vector<std::vector<std::s
|
||||
}
|
||||
}
|
||||
|
||||
-void DepHandler::query_node(std::string name, std::vector<std::vector<std::string>> &query) {
|
||||
+void DepHandler::query_node(const std::string &name, std::vector<std::vector<std::string>> &query) {
|
||||
if (!nodes.count(name)) return;
|
||||
- std::shared_ptr<Node> p = nodes[name];
|
||||
- query.emplace_back(std::vector<std::string>{name});
|
||||
- for (auto cur = p->head->next; cur != nullptr; cur = cur->next) {
|
||||
- query.emplace_back(std::vector<std::string>{name, cur->arc_name});
|
||||
- query_node(cur->arc_name, query);
|
||||
+ std::queue<std::string> q;
|
||||
+ std::unordered_set<std::string> vis;
|
||||
+ vis.insert(name);
|
||||
+ q.push(name);
|
||||
+ while (!q.empty()) {
|
||||
+ auto node = nodes[q.front()];
|
||||
+ q.pop();
|
||||
+ query.emplace_back(std::vector<std::string>{node->name});
|
||||
+ for (auto cur = node->head->next; cur != nullptr; cur = cur->next) {
|
||||
+ query.emplace_back(std::vector<std::string>{node->name, cur->arc_name});
|
||||
+ if (!vis.count(cur->arc_name)) {
|
||||
+ vis.insert(cur->arc_name);
|
||||
+ q.push(cur->arc_name);
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
-std::vector<std::string> DepHandler::get_pre_dependencies(std::string name) {
|
||||
+std::vector<std::string> DepHandler::get_pre_dependencies(const std::string &name) {
|
||||
std::vector<std::string> res;
|
||||
std::queue<std::shared_ptr<Node>> q;
|
||||
+ std::unordered_set<std::string> vis;
|
||||
+ vis.insert(name);
|
||||
q.push(nodes[name]);
|
||||
while (!q.empty()) {
|
||||
auto &node = q.front();
|
||||
q.pop();
|
||||
res.emplace_back(node->name);
|
||||
for (auto arc_node = node->head->next; arc_node != nullptr; arc_node = arc_node->next) {
|
||||
- q.push(nodes[arc_node->arc_name]);
|
||||
+ if (!vis.count(arc_node->arc_name)) {
|
||||
+ vis.insert(arc_node->arc_name);
|
||||
+ q.push(nodes[arc_node->arc_name]);
|
||||
+ }
|
||||
}
|
||||
}
|
||||
return res;
|
||||
diff --git a/src/plugin_mgr/dep_handler.h b/src/plugin_mgr/dep_handler.h
|
||||
index cc8570a..76abf49 100644
|
||||
--- a/src/plugin_mgr/dep_handler.h
|
||||
+++ b/src/plugin_mgr/dep_handler.h
|
||||
@@ -47,11 +47,11 @@ public:
|
||||
bool get_node_state(std::string name) {
|
||||
return this->nodes[name]->state;
|
||||
}
|
||||
- void add_node(std::string name, std::vector<std::string> dep_nodes = {});
|
||||
- void del_node(std::string name);
|
||||
- std::vector<std::string> get_pre_dependencies(std::string name);
|
||||
+ void add_node(const std::string &name, std::vector<std::string> dep_nodes = {});
|
||||
+ void del_node(const std::string &name);
|
||||
+ std::vector<std::string> get_pre_dependencies(const std::string &name);
|
||||
// query instance dependency
|
||||
- void query_node(std::string name, std::vector<std::vector<std::string>> &query);
|
||||
+ void query_node(const std::string &name, std::vector<std::vector<std::string>> &query);
|
||||
// query all instance dependencies
|
||||
void query_all_top(std::vector<std::vector<std::string>> &query);
|
||||
bool have_dep(const std::string &name) {
|
||||
diff --git a/src/plugin_mgr/error_code.cpp b/src/plugin_mgr/error_code.cpp
|
||||
index 6e09cb0..30cc4f8 100644
|
||||
--- a/src/plugin_mgr/error_code.cpp
|
||||
+++ b/src/plugin_mgr/error_code.cpp
|
||||
@@ -12,7 +12,7 @@ const std::unordered_map<ErrorCode, std::string> ErrorText::error_codes = {
|
||||
{ErrorCode::REMOVE_INSTANCE_HAVE_DEP, "instance with pre-dependency"},
|
||||
{ErrorCode::LOAD_PLUGIN_FILE_NOT_EXIST, "plugin file does not exist"},
|
||||
{ErrorCode::LOAD_PLUGIN_FILE_IS_NOT_SO, "file is not a plugin file"},
|
||||
- {ErrorCode::LOAD_PLUGIN_FILE_PERMISSION_DEFINED, "plugin file permission defined"},
|
||||
+ {ErrorCode::LOAD_PLUGIN_FILE_PERMISSION_DEFINED, "plugin file permission is not the specified permission"},
|
||||
{ErrorCode::LOAD_PLUGIN_EXIST, "plugin already loaded"},
|
||||
{ErrorCode::LOAD_PLUGIN_DLOPEN_FAILED, "plugin dlopen failed"},
|
||||
{ErrorCode::LOAD_PLUGIN_DLSYM_FAILED, "plugin dlsym failed"},
|
||||
diff --git a/src/plugin_mgr/message_manager.cpp b/src/plugin_mgr/message_manager.cpp
|
||||
index e2fd3b6..f081f20 100644
|
||||
--- a/src/plugin_mgr/message_manager.cpp
|
||||
+++ b/src/plugin_mgr/message_manager.cpp
|
||||
@@ -25,6 +25,9 @@ int TcpSocket::domain_listen(const char *name) {
|
||||
ERROR("[MessageManager] bind error!");
|
||||
return -1;
|
||||
}
|
||||
+ if (chmod(name, S_IRWXU | S_IRGRP | S_IXGRP) == -1) {
|
||||
+ ERROR("[MessageManager] " << name << " chmod error!");
|
||||
+ }
|
||||
if (listen(sock, 20) < 0) {
|
||||
ERROR("[MessageManager] listen error!");
|
||||
return -1;
|
||||
diff --git a/src/plugin_mgr/plugin.h b/src/plugin_mgr/plugin.h
|
||||
index 69837af..a2a1815 100644
|
||||
--- a/src/plugin_mgr/plugin.h
|
||||
+++ b/src/plugin_mgr/plugin.h
|
||||
@@ -123,8 +123,10 @@ private:
|
||||
class Plugin {
|
||||
public:
|
||||
Plugin(std::string name, PluginType type) : name(name), type(type), handler(nullptr) { }
|
||||
- ~Plugin() {
|
||||
- dlclose(handler);
|
||||
+ ~Plugin() {
|
||||
+ if (handler != nullptr) {
|
||||
+ dlclose(handler);
|
||||
+ }
|
||||
}
|
||||
int load(const std::string dl_path);
|
||||
std::string get_name() const {
|
||||
diff --git a/src/plugin_mgr/plugin_manager.cpp b/src/plugin_mgr/plugin_manager.cpp
|
||||
index 0826a60..5ef395c 100644
|
||||
--- a/src/plugin_mgr/plugin_manager.cpp
|
||||
+++ b/src/plugin_mgr/plugin_manager.cpp
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "default_path.h"
|
||||
#include "utils.h"
|
||||
#include <iostream>
|
||||
+#include <unordered_set>
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@@ -203,15 +204,15 @@ ErrorCode PluginManager::load_plugin(const std::string &name, PluginType type) {
|
||||
std::string generate_dot(MemoryStore &memory_store, const std::vector<std::vector<std::string>> &query) {
|
||||
std::string res;
|
||||
res += "digraph G {\n";
|
||||
- std::unordered_map<std::string, std::vector<std::string>> sub_graph;
|
||||
+ std::unordered_map<std::string, std::unordered_set<std::string>> sub_graph;
|
||||
for (auto &vec : query) {
|
||||
std::shared_ptr<Instance> instance = memory_store.get_instance(vec[0]);
|
||||
- sub_graph[instance->get_plugin_name()].emplace_back(vec[0]);
|
||||
+ sub_graph[instance->get_plugin_name()].insert(vec[0]);
|
||||
if (vec.size() == 1) {
|
||||
continue;
|
||||
}
|
||||
instance = memory_store.get_instance(vec[1]);
|
||||
- sub_graph[instance->get_plugin_name()].emplace_back(vec[1]);
|
||||
+ sub_graph[instance->get_plugin_name()].insert(vec[1]);
|
||||
res += vec[0] + "->" + vec[1] + ";";
|
||||
}
|
||||
int id = 0;
|
||||
@@ -371,8 +372,12 @@ void PluginManager::pre_load_plugin(PluginType type) {
|
||||
while ((entry = readdir(dir)) != nullptr) {
|
||||
std::string name = entry->d_name;
|
||||
if (end_with(name, ".so")) {
|
||||
- Message msg;
|
||||
- load_plugin(name, type);
|
||||
+ auto ret = load_plugin(name, type);
|
||||
+ if (ret != ErrorCode::OK) {
|
||||
+ WARN("[PluginManager] " << name << " plugin preload failed, because " << ErrorText::get_error_text(ret) << ".");
|
||||
+ } else {
|
||||
+ INFO("[PluginManager] " << name << " plugin loaded.");
|
||||
+ }
|
||||
}
|
||||
}
|
||||
closedir(dir);
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -1,252 +0,0 @@
|
||||
From c35c26e51d93b0eb5b0aecdf08c338178079e02a Mon Sep 17 00:00:00 2001
|
||||
From: fly_1997 <flylove7@outlook.com>
|
||||
Date: Fri, 10 May 2024 12:01:08 +0800
|
||||
Subject: [PATCH] fix load error and args parsing error printing
|
||||
|
||||
---
|
||||
src/client/arg_parse.cpp | 28 +++++++++++++++++++++++++---
|
||||
src/client/arg_parse.h | 3 +++
|
||||
src/client/cmd_handler.cpp | 28 +++++++++++-----------------
|
||||
src/plugin_mgr/config.cpp | 11 +++++------
|
||||
src/plugin_mgr/config.h | 2 +-
|
||||
src/plugin_mgr/dep_handler.cpp | 2 +-
|
||||
src/plugin_mgr/plugin_manager.cpp | 2 +-
|
||||
7 files changed, 47 insertions(+), 29 deletions(-)
|
||||
|
||||
diff --git a/src/client/arg_parse.cpp b/src/client/arg_parse.cpp
|
||||
index 70fcd4a..805f5a7 100644
|
||||
--- a/src/client/arg_parse.cpp
|
||||
+++ b/src/client/arg_parse.cpp
|
||||
@@ -62,10 +62,23 @@ void ArgParse::print_help() {
|
||||
" --help show this help message.\n";
|
||||
}
|
||||
|
||||
+void ArgParse::init_opts() {
|
||||
+ opts.insert('l');
|
||||
+ opts.insert('r');
|
||||
+ opts.insert('q');
|
||||
+ opts.insert('Q');
|
||||
+ opts.insert('e');
|
||||
+ opts.insert('d');
|
||||
+ opts.insert('L');
|
||||
+ opts.insert('i');
|
||||
+ opts.insert('t');
|
||||
+}
|
||||
+
|
||||
int ArgParse::init(int argc, char *argv[]) {
|
||||
int cmd = -1;
|
||||
int opt;
|
||||
bool help = false;
|
||||
+ init_opts();
|
||||
opterr = 0;
|
||||
while((opt = getopt_long(argc, argv, OPT_STRING.c_str(), long_options, nullptr)) != -1) {
|
||||
std::string full_opt;
|
||||
@@ -76,9 +89,15 @@ int ArgParse::init(int argc, char *argv[]) {
|
||||
case 'h':
|
||||
help = true;
|
||||
break;
|
||||
- case '?':
|
||||
- arg_error("unknown option.");
|
||||
- return -1;
|
||||
+ case '?': {
|
||||
+ std::string err;
|
||||
+ err += optopt;
|
||||
+ if (!opts.count(optopt)) {
|
||||
+ arg_error("unknown option '-" + err + "'.");
|
||||
+ } else{
|
||||
+ arg_error("option -" + err + " requires an argument.");
|
||||
+ }
|
||||
+ }
|
||||
default: {
|
||||
if (opt == 'l' || opt == 'r' || opt == 'q' || opt == 'Q' || opt == 'e' || opt == 'd' || opt == 'L' || opt == 'i') {
|
||||
if (cmd != -1) {
|
||||
@@ -94,6 +113,9 @@ int ArgParse::init(int argc, char *argv[]) {
|
||||
|
||||
}
|
||||
}
|
||||
+ if (cmd == 'l' && type.empty()) {
|
||||
+ arg_error("option '-t' is required.");
|
||||
+ }
|
||||
if (help) {
|
||||
print_help();
|
||||
exit(EXIT_SUCCESS);
|
||||
diff --git a/src/client/arg_parse.h b/src/client/arg_parse.h
|
||||
index 8535e9c..682f0e5 100644
|
||||
--- a/src/client/arg_parse.h
|
||||
+++ b/src/client/arg_parse.h
|
||||
@@ -12,12 +12,14 @@
|
||||
#ifndef CLIENT_ARG_PARSE_H
|
||||
#define CLIENT_ARG_PARSE_H
|
||||
#include <string>
|
||||
+#include <unordered_set>
|
||||
|
||||
class ArgParse {
|
||||
public:
|
||||
static void arg_error(const std::string &msg);
|
||||
static void print_help();
|
||||
int init(int argc, char *argv[]);
|
||||
+ void init_opts();
|
||||
void set_type(char* _type);
|
||||
void set_arg(char* _arg);
|
||||
std::string get_type() const {
|
||||
@@ -29,6 +31,7 @@ public:
|
||||
private:
|
||||
std::string arg;
|
||||
std::string type;
|
||||
+ std::unordered_set<char> opts;
|
||||
static const std::string OPT_STRING;
|
||||
static const int MAX_OPT_SIZE = 20;
|
||||
static const struct option long_options[MAX_OPT_SIZE];
|
||||
diff --git a/src/client/cmd_handler.cpp b/src/client/cmd_handler.cpp
|
||||
index 4fec95b..b410968 100644
|
||||
--- a/src/client/cmd_handler.cpp
|
||||
+++ b/src/client/cmd_handler.cpp
|
||||
@@ -16,14 +16,8 @@
|
||||
std::unordered_set<std::string> LoadHandler::types = {"collector", "scenario", "tune"};
|
||||
|
||||
void LoadHandler::check(const std::string &arg, const std::string &type) {
|
||||
- if (arg.empty()) {
|
||||
- ArgParse::arg_error("plugin name empty.");
|
||||
- }
|
||||
- if (type.empty()) {
|
||||
- ArgParse::arg_error("type empty.");
|
||||
- }
|
||||
if (!types.count(type)) {
|
||||
- ArgParse::arg_error("this type is not supported.");
|
||||
+ ArgParse::arg_error("type '" + type + "' is not supported.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,9 +88,9 @@ void RemoveHandler::handler(const ArgParse &arg_parse, Msg &msg) {
|
||||
|
||||
void RemoveHandler::res_handler(Msg &msg) {
|
||||
if (msg.get_opt() == Opt::RESPONSE_OK) {
|
||||
- std::cout << "plugin remove successfully.\n";
|
||||
+ std::cout << "Plugin remove successfully.\n";
|
||||
} else {
|
||||
- std::cout << "plugin remove failed, because " << msg.payload(0) << ".\n";
|
||||
+ std::cout << "Plugin remove failed, because " << msg.payload(0) << ".\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,9 +135,9 @@ void EnabledHandler::handler(const ArgParse &arg_parse, Msg &msg) {
|
||||
|
||||
void EnabledHandler::res_handler(Msg &msg) {
|
||||
if (msg.get_opt() == Opt::RESPONSE_OK) {
|
||||
- std::cout << "instance enabled successfully.\n";
|
||||
+ std::cout << "Instance enabled successfully.\n";
|
||||
} else {
|
||||
- std::cout << "instance enabled failed, because "<< msg.payload(0) << ".\n";
|
||||
+ std::cout << "Instance enabled failed, because "<< msg.payload(0) << ".\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,9 +149,9 @@ void DisabledHandler::handler(const ArgParse &arg_parse, Msg &msg) {
|
||||
|
||||
void DisabledHandler::res_handler(Msg &msg) {
|
||||
if (msg.get_opt() == Opt::RESPONSE_OK) {
|
||||
- std::cout << "instance disabled successfully.\n";
|
||||
+ std::cout << "Instance disabled successfully.\n";
|
||||
} else {
|
||||
- std::cout << "instance disabled failed, because "<< msg.payload(0) << ".\n";
|
||||
+ std::cout << "Instance disabled failed, because "<< msg.payload(0) << ".\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,10 +161,10 @@ void ListHandler::handler(const ArgParse &arg_parse, Msg &msg) {
|
||||
|
||||
void ListHandler::res_handler(Msg &msg) {
|
||||
if (msg.get_opt() == Opt::RESPONSE_ERROR) {
|
||||
- std::cerr << "query list failed, because "<< msg.payload(0) << ".\n";
|
||||
+ std::cerr << "Query list failed, because "<< msg.payload(0) << ".\n";
|
||||
return;
|
||||
}
|
||||
- std::cout << "plugin list as follows.\n";
|
||||
+ std::cout << "Plugin list as follows.\n";
|
||||
std::cout << "------------------------------------------------------------\n";
|
||||
for (int i = 0; i < msg.payload_size(); ++i) {
|
||||
std::cout << msg.payload(i);
|
||||
@@ -186,13 +180,13 @@ void InstallHandler::handler(const ArgParse &arg_parse, Msg &msg) {
|
||||
|
||||
void InstallHandler::res_handler(Msg &msg) {
|
||||
if (msg.get_opt() == Opt::RESPONSE_ERROR) {
|
||||
- std::cout << "download failed, because " << msg.payload(0) <<": " << this->arg.c_str() << '\n';
|
||||
+ std::cout << "Download failed, because " << msg.payload(0) <<": " << this->arg.c_str() << '\n';
|
||||
return;
|
||||
}
|
||||
std::string path = this->arg;
|
||||
std::string url = msg.payload(0);
|
||||
if (!download(url, path)) {
|
||||
- std::cout << "download failed, please check url or your network.\n";
|
||||
+ std::cout << "Download failed, please check url or your network.\n";
|
||||
return;
|
||||
}
|
||||
std::string command = "rpm -ivh " + path;
|
||||
diff --git a/src/plugin_mgr/config.cpp b/src/plugin_mgr/config.cpp
|
||||
index 3c76e8e..f50399b 100644
|
||||
--- a/src/plugin_mgr/config.cpp
|
||||
+++ b/src/plugin_mgr/config.cpp
|
||||
@@ -84,16 +84,15 @@ bool Config::load(const std::string path) {
|
||||
for (int i = 0; i < enable_list.size(); ++i) {
|
||||
YAML::Node plugin = enable_list[i]["name"];
|
||||
std::string name = enable_list[i]["name"].as<std::string>();
|
||||
+ YAML::Node instances = enable_list[i]["instances"];
|
||||
EnableItem enable_item(name);
|
||||
- if (plugin.IsScalar()) {
|
||||
+ if (instances.IsNull()) {
|
||||
enable_item.set_enabled(true);
|
||||
- } else if (plugin.IsSequence()) {
|
||||
- for (int j = 0; j < plugin.size(); ++j) {
|
||||
- std::string i_name = plugin[j].as<std::string>();
|
||||
+ } else {
|
||||
+ for (int j = 0; j < instances.size(); ++j) {
|
||||
+ std::string i_name = instances[j].as<std::string>();
|
||||
enable_item.add_instance(i_name);
|
||||
}
|
||||
- } else {
|
||||
- continue;
|
||||
}
|
||||
this->enable_list.emplace_back(enable_item);
|
||||
}
|
||||
diff --git a/src/plugin_mgr/config.h b/src/plugin_mgr/config.h
|
||||
index 5ab7672..6d0ee4d 100644
|
||||
--- a/src/plugin_mgr/config.h
|
||||
+++ b/src/plugin_mgr/config.h
|
||||
@@ -52,7 +52,7 @@ namespace std {
|
||||
|
||||
class EnableItem {
|
||||
public:
|
||||
- EnableItem(std::string name) : name(name) { }
|
||||
+ EnableItem(std::string name) : name(name), enabled(false) { }
|
||||
void set_enabled(bool enabled) {
|
||||
this->enabled = enabled;
|
||||
}
|
||||
diff --git a/src/plugin_mgr/dep_handler.cpp b/src/plugin_mgr/dep_handler.cpp
|
||||
index 652fdce..816056d 100644
|
||||
--- a/src/plugin_mgr/dep_handler.cpp
|
||||
+++ b/src/plugin_mgr/dep_handler.cpp
|
||||
@@ -132,7 +132,7 @@ void DepHandler::query_node(const std::string &name, std::vector<std::vector<std
|
||||
query.emplace_back(std::vector<std::string>{node->name});
|
||||
for (auto cur = node->head->next; cur != nullptr; cur = cur->next) {
|
||||
query.emplace_back(std::vector<std::string>{node->name, cur->arc_name});
|
||||
- if (!vis.count(cur->arc_name)) {
|
||||
+ if (!vis.count(cur->arc_name) && nodes.count(cur->arc_name)) {
|
||||
vis.insert(cur->arc_name);
|
||||
q.push(cur->arc_name);
|
||||
}
|
||||
diff --git a/src/plugin_mgr/plugin_manager.cpp b/src/plugin_mgr/plugin_manager.cpp
|
||||
index 5ef395c..77acc40 100644
|
||||
--- a/src/plugin_mgr/plugin_manager.cpp
|
||||
+++ b/src/plugin_mgr/plugin_manager.cpp
|
||||
@@ -461,7 +461,7 @@ int PluginManager::run() {
|
||||
PluginType type = plugin_types[msg.get_payload(1)];
|
||||
ErrorCode ret_code = load_plugin(plugin_name, type);
|
||||
if(ret_code == ErrorCode::OK) {
|
||||
- INFO("[PluginManager] " << plugin_name << "plugin loaded.");
|
||||
+ INFO("[PluginManager] " << plugin_name << " plugin loaded.");
|
||||
res.set_opt(Opt::RESPONSE_OK);
|
||||
std::string lack_dep = instance_dep_check(plugin_name);
|
||||
if (!lack_dep.empty()) {
|
||||
--
|
||||
2.33.0
|
||||
|
||||
Binary file not shown.
BIN
oeAware-manager-v1.0.2.tar.gz
Normal file
BIN
oeAware-manager-v1.0.2.tar.gz
Normal file
Binary file not shown.
@ -1,16 +1,13 @@
|
||||
Name: oeAware-manager
|
||||
Version: v1.0.0
|
||||
Release: 5
|
||||
Version: v1.0.2
|
||||
Release: 3
|
||||
Summary: OeAware server and client
|
||||
License: MulanPSL2
|
||||
URL: https://gitee.com/openeuler/%{name}
|
||||
Source0: %{name}-%{version}.tar.gz
|
||||
Patch1: 0001-fix-remove-plugin-bug-and-refactor.patch
|
||||
Patch2: 0002-add-error-code-and-replace-raw-poniters-with-smart-p.patch
|
||||
Patch3: 0003-add-client-error-description-extract-class-and-fix-b.patch
|
||||
Patch4: 0004-fix-auto-enable-error-and-check-plugin-list-config.patch
|
||||
Patch5: 0005-modify-logs-sock-file-permission-and-fix-service-fil.patch
|
||||
Patch6: 0006-fix-load-error-and-args-parsing-error-printing.patch
|
||||
Patch1: 0001-plugin_mgr-logger-apppend-to-logfile-rather-than-tru.patch
|
||||
Patch2: 0002-fix-threads-are-still-bound-after-systemctl-stop-oea.patch
|
||||
Patch3: 0003-fix-coredump-when-process-exits.patch
|
||||
|
||||
BuildRequires: cmake make gcc-c++
|
||||
BuildRequires: boost-devel
|
||||
@ -19,9 +16,10 @@ BuildRequires: log4cplus-devel
|
||||
BuildRequires: yaml-cpp-devel
|
||||
BuildRequires: gtest-devel gmock-devel
|
||||
|
||||
Requires: oeAware-collector
|
||||
Requires: oeAware-scenario
|
||||
Requires: graphviz
|
||||
Requires: oeAware-collector >= v1.0.2
|
||||
Requires: oeAware-scenario >= v1.0.2
|
||||
Requires: oeAware-tune >= v1.0.0
|
||||
Requires: graphviz yaml-cpp curl log4cplus boost systemd
|
||||
|
||||
%description
|
||||
%{name} provides server and client to manager plugins.
|
||||
@ -45,7 +43,13 @@ install -D -p -m 0644 oeaware.service %{buildroot}%{_unitdir}/oeaware.service
|
||||
%systemd_preun oeaware.service
|
||||
|
||||
%post
|
||||
%systemd_post oeaware.service
|
||||
systemctl start oeaware.service
|
||||
|
||||
%posttrans
|
||||
. /etc/os-release || :
|
||||
if [ "${VERSION}" == "22.03 (LTS-SP4)" ]; then
|
||||
systemctl enable oeaware.service
|
||||
fi
|
||||
|
||||
%files
|
||||
%attr(0750, root, root) %{_bindir}/oeaware
|
||||
@ -54,6 +58,37 @@ install -D -p -m 0644 oeaware.service %{buildroot}%{_unitdir}/oeaware.service
|
||||
%attr(0644, root, root) %{_unitdir}/oeaware.service
|
||||
|
||||
%changelog
|
||||
* Mon Jul 8 2024 fly_1997 <flylove7@outlook.com> -v1.0.2-3
|
||||
- add automatic startup based on the version
|
||||
- fix coredump when process exits
|
||||
- modify logger mode to append
|
||||
|
||||
* Thu Jun 27 2024 fly_1997 <flylove7@outlook.com> -v1.0.2-2
|
||||
- add enable automatic startup
|
||||
|
||||
* Thu Jun 20 2024 fly_1997 <flylove7@outlook.com> -v1.0.2-1
|
||||
- update version to v1.0.2-1
|
||||
|
||||
* Fri Jun 14 2024 fly_1997 <flylove7@outlook.com> -v1.0.1-6
|
||||
- fix dependency error and add enable failed logs
|
||||
- fix dependency disabled failed and pre-enable illegal plugin
|
||||
|
||||
* Wed Jun 12 2024 fly_1997 <flylove7@outlook.com> -v1.0.1-5
|
||||
- add Requires
|
||||
|
||||
* Wed Jun 5 2024 fly_1997 <flylove7@outlook.com> -v1.0.1-4
|
||||
- add dynamic dependencncy adjustment
|
||||
|
||||
* Fri May 31 2024 fly_1997 <flylove7@outlook.com> -v1.0.1-3
|
||||
- refactor instance interfaces and add signal function
|
||||
|
||||
* Wed May 15 2024 fly_1997 <flylove7@outlook.com> -v1.0.1-2
|
||||
- fix pre-enable failed, dependencies missing error, memory leak
|
||||
- fix warning message
|
||||
|
||||
* Sat May 11 2024 fly_1997 <flylove7@outlook.com> -v1.0.1-1
|
||||
- update version to v1.0.1
|
||||
|
||||
* Wed May 8 2024 fly_1997 <flylove7@outlook.com> -v1.0.0-5
|
||||
- fix systemd service uninstallation issue
|
||||
- fix load error and args parsing error printing
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user