Skip to content

Commit

Permalink
SymLinkName, PidFileName, and AgentPrefix support logtail_mode. (#1904)
Browse files Browse the repository at this point in the history
  • Loading branch information
quzard authored Nov 25, 2024
1 parent ae008fc commit 0ff6f89
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
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
3 changes: 3 additions & 0 deletions core/app_config/AppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,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
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

0 comments on commit 0ff6f89

Please sign in to comment.