Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SymLinkName, PidFileName, and AgentPrefix support logtail_mode. #1904

Merged
merged 4 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions core/app_config/AppConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "common/FileSystemUtil.h"
#include "common/JsonUtil.h"
#include "common/LogtailCommonFlags.h"
#include "common/version.h"
#include "config/InstanceConfigManager.h"
#include "config/watcher/InstanceConfigWatcher.h"
#include "file_server/ConfigManager.h"
Expand All @@ -39,6 +40,10 @@

using namespace std;

#define ILOGTAIL_PREFIX "ilogtail_"
#define ILOGTAIL_PIDFILE_SUFFIX ".pid"
#define LOONGCOLLECTOR_PREFIX "loongcollector_"

DEFINE_FLAG_BOOL(logtail_mode, "logtail mode", false);
DEFINE_FLAG_INT32(max_buffer_num, "max size", 40);
DEFINE_FLAG_INT32(pub_max_buffer_num, "max size", 8);
Expand Down Expand Up @@ -520,7 +525,7 @@ std::string GetAgentName() {
return "ilogtail";
} else {
return "loongcollector";
}
}
}

std::string GetMonitorInfoFileName() {
Expand All @@ -531,6 +536,30 @@ std::string GetMonitorInfoFileName() {
}
}

std::string GetSymLinkName() {
if (BOOL_FLAG(logtail_mode)) {
return GetProcessExecutionDir() + "ilogtail";
} else {
return GetProcessExecutionDir() + "loongcollector";
}
}

std::string GetPidFileName() {
if (BOOL_FLAG(logtail_mode)) {
return GetProcessExecutionDir() + ILOGTAIL_PREFIX + ILOGTAIL_VERSION + ILOGTAIL_PIDFILE_SUFFIX;
} else {
return GetAgentRunDir() + "loongcollector.pid";
}
}

std::string GetAgentPrefix() {
if (BOOL_FLAG(logtail_mode)) {
return ILOGTAIL_PREFIX;
} else {
return LOONGCOLLECTOR_PREFIX;
}
}

AppConfig::AppConfig() {
LOG_INFO(sLogger, ("AppConfig AppConfig", "success"));
SetIlogtailConfigJson("");
Expand Down Expand Up @@ -1509,8 +1538,8 @@ void AppConfig::ReadFlagsFromMap(const std::unordered_map<std::string, std::stri
* - 记录无法转换的值
*/
void AppConfig::RecurseParseJsonToFlags(const Json::Value& confJson, std::string prefix) {
const static unordered_set<string> sIgnoreKeySet = {"data_server_list", "legacy_data_server_list"};
const static unordered_set<string> sForceKeySet = {"config_server_address_list", "config_server_list"};
const static unordered_set<string> sIgnoreKeySet = {"data_server_list", "data_servers"};
const static unordered_set<string> sForceKeySet = {"config_server_address_list", "config_servers"};
for (auto name : confJson.getMemberNames()) {
auto jsonvalue = confJson[name];
string fullName;
Expand Down
5 changes: 4 additions & 1 deletion core/app_config/AppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ std::string GetVersionTag();
std::string GetGoPluginCheckpoint();
std::string GetAgentName();
std::string GetMonitorInfoFileName();
std::string GetSymLinkName();
std::string GetPidFileName();
std::string GetAgentPrefix();

template <class T>
class DoubleBuffer {
Expand Down Expand Up @@ -304,7 +307,7 @@ class AppConfig {

public:
AppConfig();
~AppConfig() {};
~AppConfig(){};

void LoadInstanceConfig(const std::map<std::string, std::shared_ptr<InstanceConfig>>&);

Expand Down
3 changes: 0 additions & 3 deletions core/common/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,4 @@ extern const char* const ILOGTAIL_UPDATE_SUFFIX;
extern const char* const ILOGTAIL_GIT_HASH;
extern const char* const ILOGTAIL_BUILD_DATE;

#define ILOGTAIL_PREFIX "ilogtail_"
#define ILOGTAIL_PIDFILE_SUFFIX ".pid"

#endif
Loading