diff --git a/core/dependencies.cmake b/core/dependencies.cmake index d72b3a73f1..d523d93326 100644 --- a/core/dependencies.cmake +++ b/core/dependencies.cmake @@ -88,15 +88,6 @@ foreach (DEP_NAME ${DEP_NAME_LIST}) endif () endforeach (DEP_NAME) -# spdlog, replace implementation. -if (spdlog_${INCLUDE_DIR_SUFFIX}) - file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/deps/spdlog/sinks/rotating_file_sink-inl.h - DESTINATION "${spdlog_${INCLUDE_DIR_SUFFIX}}/spdlog/sinks") -else () - file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/deps/spdlog/sinks/rotating_file_sink-inl.h - DESTINATION ${DEPS_INCLUDE_ROOT}/spdlog/sinks) -endif () - # gtest macro(link_gtest target_name) if (gtest_${LINK_OPTION_SUFFIX}) diff --git a/core/deps/spdlog/sinks/rotating_file_sink-inl.h b/core/deps/spdlog/sinks/rotating_file_sink-inl.h deleted file mode 100644 index 6e666151f3..0000000000 --- a/core/deps/spdlog/sinks/rotating_file_sink-inl.h +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright(c) 2015-present, Gabi Melman & spdlog contributors. -// Distributed under the MIT License (http://opensource.org/licenses/MIT) - -#pragma once - -#ifndef SPDLOG_HEADER_ONLY -#include -#endif - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -namespace spdlog { -namespace sinks { - -template -SPDLOG_INLINE rotating_file_sink::rotating_file_sink( - filename_t base_filename, std::size_t max_size, std::size_t max_files, bool rotate_on_open, const file_event_handlers &event_handlers) - : base_filename_(std::move(base_filename)) - , max_size_(max_size) - , max_files_(max_files) - , file_helper_{event_handlers} -{ - if (max_size == 0) - { - throw_spdlog_ex("rotating sink constructor: max_size arg cannot be zero"); - } - - if (max_files > 200000) - { - throw_spdlog_ex("rotating sink constructor: max_files arg cannot exceed 200000"); - } - // baoze.yyh: rotate at beginning. - auto fn = calc_filename(base_filename_, 0); - auto existing = details::os::path_exists(fn); - file_helper_.open(fn); - if (existing) { rotate_(); } - current_size_ = file_helper_.size(); // expensive. called only once -} - -// calc filename according to index and file extension if exists. -// e.g. calc_filename("logs/mylog.txt, 3) => "logs/mylog.3.txt". -template -SPDLOG_INLINE filename_t rotating_file_sink::calc_filename(const filename_t &filename, std::size_t index) -{ - if (index == 0u) - { - return filename; - } - - filename_t basename, ext; - std::tie(basename, ext) = details::file_helper::split_by_extension(filename); - return fmt_lib::format(SPDLOG_FILENAME_T("{}.{}{}"), basename, index, ext); -} - -template -SPDLOG_INLINE filename_t rotating_file_sink::filename() -{ - std::lock_guard lock(base_sink::mutex_); - return file_helper_.filename(); -} - -template -SPDLOG_INLINE void rotating_file_sink::sink_it_(const details::log_msg &msg) -{ - memory_buf_t formatted; - base_sink::formatter_->format(msg, formatted); - auto new_size = current_size_ + formatted.size(); - - // rotate if the new estimated file size exceeds max size. - // rotate only if the real size > 0 to better deal with full disk (see issue #2261). - // we only check the real size when new_size > max_size_ because it is relatively expensive. - if (new_size > max_size_) - { - file_helper_.flush(); - if (file_helper_.size() > 0) - { - rotate_(); - new_size = formatted.size(); - } - } - file_helper_.write(formatted); - current_size_ = new_size; -} - -template -SPDLOG_INLINE void rotating_file_sink::flush_() -{ - file_helper_.flush(); -} - -// Rotate files: -// log.txt -> log.1.txt -// log.1.txt -> log.2.txt -// log.2.txt -> log.3.txt -// log.3.txt -> delete -template -SPDLOG_INLINE void rotating_file_sink::rotate_() -{ - using details::os::filename_to_str; - using details::os::path_exists; - - file_helper_.close(); - for (auto i = max_files_; i > 0; --i) - { - filename_t src = calc_filename(base_filename_, i - 1); - if (!path_exists(src)) - { - continue; - } - filename_t target = calc_filename(base_filename_, i); - - if (!rename_file_(src, target)) - { - // if failed try again after a small delay. - // this is a workaround to a windows issue, where very high rotation - // rates can cause the rename to fail with permission denied (because of antivirus?). - details::os::sleep_for_millis(100); - if (!rename_file_(src, target)) - { - file_helper_.reopen(true); // truncate the log file anyway to prevent it to grow beyond its limit! - current_size_ = 0; - throw_spdlog_ex("rotating_file_sink: failed renaming " + filename_to_str(src) + " to " + filename_to_str(target), errno); - } - } - } - file_helper_.reopen(true); -} - -// delete the target if exists, and rename the src file to target -// return true on success, false otherwise. -template -SPDLOG_INLINE bool rotating_file_sink::rename_file_(const filename_t &src_filename, const filename_t &target_filename) -{ - // try to delete the target file in case it already exists. - (void)details::os::remove(target_filename); - return details::os::rename(src_filename, target_filename) == 0; -} - -} // namespace sinks -} // namespace spdlog diff --git a/docker/Dockerfile_production b/docker/Dockerfile_production index 602ccd4915..edcb95030c 100644 --- a/docker/Dockerfile_production +++ b/docker/Dockerfile_production @@ -25,7 +25,20 @@ MAINTAINER TomYu yyuuttaaoo@gmail.com ENV container docker -RUN curl -L -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo + +ARG TARGETPLATFORM + +RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ + echo "Building for AMD64"; \ + curl -L -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo; \ + elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ + echo "Building for ARM64"; \ + curl -L -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-altarch-7.repo; \ + else \ + echo "Unsupported platform: $TARGETPLATFORM"; \ + exit 1; \ + fi + RUN yum update -y && yum upgrade -y && yum -y clean all && rm -fr /var/cache && rm -rf /core.* diff --git a/scripts/update_version.sh b/scripts/update_version.sh index a93b996afe..42e7fa8cbd 100755 --- a/scripts/update_version.sh +++ b/scripts/update_version.sh @@ -42,7 +42,7 @@ sed -i "s/VERSION=\${3:-.*}/VERSION=\${3:-$version}/g" scripts/*.sh sed -i "s/VERSION=\${4:-.*}/VERSION=\${4:-$version}/g" scripts/*.sh sed -i "s/DIST_DIR=\${2:-loongcollector-.*}/DIST_DIR=\${2:-loongcollector-$version}/g" scripts/dist.sh sed -i "s/^set ILOGTAIL_VERSION=.*/set ILOGTAIL_VERSION=$version/g" scripts/*.bat -sed -i "s/image: aliyun\\/loongcollector:.*/image: aliyun\\/loongcollector:$version/g" test/engine/boot/compose.go +sed -i "s/image: aliyun\\/loongcollector:.*/image: aliyun\\/loongcollector:$version/g" test/engine/setup/dockercompose/compose.go # Docs sed -i "s/aliyun\\/loongcollector:[^\` ]*/aliyun\\/loongcollector:$version/g" \