Skip to content

Commit

Permalink
Merge remote-tracking branch 'alibaba/main' into process_tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Abingcbc committed Jan 12, 2025
2 parents 9fbd7e5 + 087489d commit 2dd7934
Show file tree
Hide file tree
Showing 58 changed files with 965 additions and 490 deletions.
3 changes: 3 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
FROM sls-opensource-registry.cn-shanghai.cr.aliyuncs.com/loongcollector-community-edition/loongcollector-build-linux:2.1.1

ARG USERNAME=admin
ARG USER_PASSWORD
USER root

RUN wget https://ilogtail-community-edition.oss-cn-shanghai.aliyuncs.com/toolchain/glibc-2.18.tar.gz && \
Expand All @@ -38,8 +39,10 @@ RUN source /tmp/.env && rm /tmp/.env; \
groupadd --gid $GROUP_GID $GROUPNAME; \
fi; \
useradd --uid $USER_UID --gid $GROUP_GID -m $USERNAME; \
if [ -n "$USER_PASSWORD" ]; then echo "$USERNAME:$USER_PASSWORD" | chpasswd; fi; \
echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME; \
chmod 0440 /etc/sudoers.d/$USERNAME; \
chown -R $USERNAME:$GROUPNAME /opt $(eval echo ~$USERNAME); \
chmod -R 755 $(eval echo ~$USERNAME);

USER $USERNAME
Expand Down
37 changes: 35 additions & 2 deletions core/app_config/AppConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,32 @@ std::string GetAgentGoLogConfDir() {
return dir;
}

std::string GetBufferFileDir() {
static std::string dir;
if (!dir.empty()) {
return dir;
}
if (BOOL_FLAG(logtail_mode)) {
dir = GetProcessExecutionDir();
} else {
dir = GetAgentDataDir();
}
return dir;
}

std::string GetHistoryDataPath() {
static std::string dir;
if (!dir.empty()) {
return dir;
}
if (BOOL_FLAG(logtail_mode)) {
dir = GetProcessExecutionDir();
} else {
dir = GetAgentDataDir();
}
return dir;
}

std::string GetAgentGoCheckpointDir() {
static std::string dir;
if (!dir.empty()) {
Expand All @@ -344,11 +370,18 @@ std::string GetAgentDataDir() {
dir = GetProcessExecutionDir();
#else
if (BOOL_FLAG(logtail_mode)) {
dir = GetProcessExecutionDir();
dir = AppConfig::GetInstance()->GetLoongcollectorConfDir() + PATH_SEPARATOR + "checkpoint";
} else {
dir = STRING_FLAG(loongcollector_data_dir) + PATH_SEPARATOR;
}
#endif
if (!CheckExistance(dir)) {
if (Mkdirs(dir)) {
LOG_INFO(sLogger, ("create data dir success", dir));
} else {
LOG_ERROR(sLogger, ("create data dir failed", dir));
}
}
return dir;
}

Expand Down Expand Up @@ -392,7 +425,7 @@ std::string GetAgentDockerPathConfig() {
return file_path;
}
if (BOOL_FLAG(logtail_mode)) {
file_path = GetAgentDataDir() + STRING_FLAG(ilogtail_docker_file_path_config);
file_path = GetProcessExecutionDir() + STRING_FLAG(ilogtail_docker_file_path_config);
} else {
file_path = GetAgentDataDir() + "docker_path_config.json";
}
Expand Down
2 changes: 2 additions & 0 deletions core/app_config/AppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ std::string GetAgentConfDir();
std::string GetAgentRunDir();
std::string GetAgentThirdPartyDir();

std::string GetBufferFileDir();
std::string GetHistoryDataPath();
std::string GetAgentGoCheckpointDir();
std::string GetAgentGoLogConfDir();
std::string GetAgentPrometheusAuthorizationPath();
Expand Down
9 changes: 7 additions & 2 deletions core/application/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,12 @@ void Application::Init() {
}

AppConfig::GetInstance()->LoadAppConfig(GetAgentConfigFile());

#ifdef __ENTERPRISE__
if (!InstanceIdentity::Instance()->InitFromFile()) {
InstanceIdentity::Instance()->InitFromNetwork();
InstanceIdentity::Instance()->DumpInstanceIdentity();
}
#endif
// Initialize basic information: IP, hostname, etc.
LoongCollectorMonitor::GetInstance();
#ifdef __ENTERPRISE__
Expand Down Expand Up @@ -168,7 +173,7 @@ void Application::Init() {
appInfoJson["UUID"] = Json::Value(Application::GetInstance()->GetUUID());
appInfoJson["instance_id"] = Json::Value(Application::GetInstance()->GetInstanceId());
#ifdef __ENTERPRISE__
appInfoJson["host_id"] = Json::Value(HostIdentifier::Instance()->GetHostId().id);
appInfoJson["host_id"] = Json::Value(InstanceIdentity::Instance()->GetEntity()->GetHostID().to_string());
appInfoJson[GetVersionTag()] = Json::Value(ILOGTAIL_VERSION);
#else
appInfoJson[GetVersionTag()] = Json::Value(string(ILOGTAIL_VERSION) + " Community Edition");
Expand Down
Loading

0 comments on commit 2dd7934

Please sign in to comment.