Skip to content

Commit

Permalink
Merge pull request #7 from iqoption/build
Browse files Browse the repository at this point in the history
Build
  • Loading branch information
devkpv authored Mar 2, 2020
2 parents 5e9a01f + cdd2503 commit 8f26096
Show file tree
Hide file tree
Showing 25 changed files with 144 additions and 42 deletions.
22 changes: 22 additions & 0 deletions .build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
ARG TAG=ubuntu18

FROM neogenie/iqlogger_builder:$TAG

ARG VERSION
ARG TAG
ARG ARCH
ARG UBUNTU

ARG CI_PIPELINE_ID
ARG CI_COMMIT_REF_NAME
ARG CI_COMMIT_MESSAGE
ARG CI_COMMIT_SHA
ARG CI_USER

ADD . /iqlogger
WORKDIR iqlogger

RUN .build/${TAG}.sh

RUN cp iqlogger .build_deb/${TAG}/usr/local/bin/
RUN bash .build_deb/create-deb.sh
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions .build_deb/create-deb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

rm .build_deb/${TAG}/var/log/iqlogger/.gitkeep
rm .build_deb/${TAG}/var/lib/iqlogger/.gitkeep
rm .build_deb/${TAG}/usr/local/bin/.gitkeep
cd .build_deb/${TAG}
fpm -s dir -t deb -a ${ARCH} -n iqlogger -v ${VERSION}-${UBUNTU} -m [email protected] \
-d libtbb2 -d zlib1g \
--pre-install ../pre-install.sh \
--after-install ../post-install.sh \
--vendor [email protected] \
--config-files etc/iqlogger \
etc/ usr/ var/
15 changes: 0 additions & 15 deletions .build_deb/create_deb_16.sh

This file was deleted.

15 changes: 0 additions & 15 deletions .build_deb/create_deb_18.sh

This file was deleted.

File renamed without changes.
File renamed without changes.
46 changes: 46 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
os: linux
dist: xenial
language: shell

services:
- docker

jobs:
include:
- env:
- TAG=ubuntu16
- ARCH=amd64
- UBUNTU=xenial
- env:
- TAG=ubuntu18
- ARCH=amd64
- UBUNTU=bionic

script:
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin;
- export VERSION=`cat ./version`
- chmod +x .build/ubuntu16.sh
- chmod +x .build/ubuntu18.sh
- docker build -t builder --build-arg VERSION="$VERSION" --build-arg TAG="$TAG" --build-arg ARCH="$ARCH" --build-arg UBUNTU="$UBUNTU" --build-arg CI_PIPELINE_ID="$TRAVIS_BUILD_NUMBER" --build-arg CI_COMMIT_REF_NAME="$TRAVIS_BRANCH" --build-arg CI_COMMIT_SHA="$TRAVIS_COMMIT" --build-arg CI_COMMIT_MESSAGE="$TRAVIS_COMMIT_MESSAGE" --build-arg CI_USER="$USER" -f .build/Dockerfile .
- docker create --name builder builder
- mkdir -p ${TRAVIS_BUILD_DIR}/build
- docker cp builder:/iqlogger/iqlogger ${TRAVIS_BUILD_DIR}/build/
- docker cp builder:/iqlogger/.build_deb/${TAG}/iqlogger_$VERSION-${UBUNTU}_$ARCH.deb ${TRAVIS_BUILD_DIR}/build/
- docker rm builder
- ls -alh ${TRAVIS_BUILD_DIR}/build
- cp ${TRAVIS_BUILD_DIR}/build/iqlogger .docker/usr/local/bin/;
- if [[ "$TAG" == "ubuntu18" ]]; then
docker build -t ${DOCKER_REPOSITORY}:$VERSION .docker;
docker push ${DOCKER_REPOSITORY}:$VERSION;
docker tag ${DOCKER_REPOSITORY}:$VERSION ${DOCKER_REPOSITORY}:latest;
docker push ${DOCKER_REPOSITORY}:latest;
fi

deploy:
provider: releases
api_key: "$GITHUB_TOKEN"
file_glob: true
file: ${TRAVIS_BUILD_DIR}/build/*.deb
skip_cleanup: true
on:
tags: true
49 changes: 46 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,64 @@ configure_file (
"${PROJECT_BINARY_DIR}/src/Version.h"
)

if (DEFINED ENV{CI_PIPELINE_ID})
set(BUILD_ID "$ENV{CI_PIPELINE_ID}")
else ()
set(BUILD_ID "undefined")
endif ()
message("Build id: ${BUILD_ID}")

if (DEFINED ENV{CI_COMMIT_REF_NAME})
set(BUILD_COMMIT "$ENV{CI_COMMIT_SHA} ($ENV{CI_COMMIT_MESSAGE})")
set(GIT_VERSION "$ENV{CI_COMMIT_REF_NAME}")
else ()
set(BUILD_COMMIT "undefined (undefined)")
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif ()
message("Build commit: ${BUILD_COMMIT}")
message("Git version: ${GIT_VERSION}")

string(TIMESTAMP BUILD_DATE_TIME "%Y-%m-%d %H:%M:%S UTC" UTC)

if (DEFINED ENV{CI_USER})
set(BUILD_USER "$ENV{CI_USER}")
else ()
set(BUILD_USER "undefined")
endif ()

message("Build date: ${BUILD_DATE_TIME}")
message("Build user: ${BUILD_USER}")

configure_file (
"${PROJECT_SOURCE_DIR}/src/config/Config.h.in"
"${PROJECT_BINARY_DIR}/src/config/Config.h"
)

set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME ON)

find_package(Boost COMPONENTS system iostreams program_options REQUIRED)
find_package(Boost COMPONENTS system iostreams program_options regex REQUIRED)

if(NOT Boost_FOUND)
message(FATAL "Boost not found!")
endif()

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CPP_FILESYSTEM_LIB "c++fs")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CPP_FILESYSTEM_LIB "stdc++fs")
set(EC_STATIC_GLIBC ON)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
message(FATAL "Intel is not supported!")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
message(FATAL "MS Visual Studio is not supported!")
endif()

include_directories("${PROJECT_SOURCE_DIR}/src")
include_directories(${Boost_INCLUDE_DIRS})

Expand Down Expand Up @@ -80,7 +123,7 @@ add_executable(${PROJECT_NAME} src/main.cpp
src/formats/gelf/GelfMessage.cpp
)

set(IQLOGGER_LIBS "${IQLOGGER_INPUT_LIBRARIES}${IQLOGGER_OUTPUT_LIBRARIES}${IQLOGGER_STATS_LIBRARIES};${Boost_LIBRARIES};tbb;pthread;z;stdc++fs")
set(IQLOGGER_LIBS "${IQLOGGER_INPUT_LIBRARIES}${IQLOGGER_OUTPUT_LIBRARIES}${IQLOGGER_STATS_LIBRARIES};${Boost_LIBRARIES};${CPP_FILESYSTEM_LIB};tbb;pthread;z;")

if(IQLOGGER_WITH_PROCESSOR)
message("Processor detected")
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
IQ Logger
=======================

[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Build Status](https://travis-ci.org/iqoption/iqlogger.svg?branch=master)](https://travis-ci.org/iqoption/iqlogger)

**IQLogger** - высокопроизводительное легковесное решение для сбора, процессинга, транспорта и балансировки логов из любых источников, включая:

- логи своих приложений
Expand Down
7 changes: 4 additions & 3 deletions src/inputs/Record.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,17 @@ namespace iqlogger::inputs {

public:

template <typename = std::enable_if_t<std::is_same<typename T::SourceT, void>::value>>
template <typename ST = typename T::SourceT, typename = std::enable_if_t<std::is_same_v<ST, void>>>
explicit Record(RecordDataT&& data) : m_data(std::move(data))
{
TRACE("inputs::Record::Record()");
}

template <
class U,
typename = std::enable_if_t<std::is_constructible<typename T::SourceT, std::decay_t<U>>::value>,
typename = std::enable_if_t<!std::is_same<typename T::SourceT, void>::value>
typename ST = typename T::SourceT,
typename = std::enable_if_t<std::is_constructible_v<ST, std::decay_t<U>>>,
typename = std::enable_if_t<!std::is_same_v<ST, void>>
>
explicit Record(RecordDataT&& data, U&& source) : m_data(std::move(data)), m_source(std::forward<U>(source))
{
Expand Down
6 changes: 4 additions & 2 deletions src/inputs/gelf/tcp/Server.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ namespace iqlogger::inputs::gelf::tcp {
public:

explicit Server(RecordQueuePtr<Gelf> queuePtr, boost::asio::io_service &io_service, short port)
: m_acceptor(io_service, tcp::endpoint(tcp::v4(), port)),
: m_io_service(io_service),
m_acceptor(io_service, tcp::endpoint(tcp::v4(), port)),
m_queuePtr(queuePtr)
{
start_accept();
Expand All @@ -128,7 +129,7 @@ namespace iqlogger::inputs::gelf::tcp {
void start_accept()
{
tcp_connection::pointer new_connection =
tcp_connection::create(m_acceptor.get_io_service(), m_queuePtr);
tcp_connection::create(m_io_service, m_queuePtr);

auto handler = [this, new_connection](const boost::system::error_code &error) {
handle_accept(new_connection, error);
Expand All @@ -152,6 +153,7 @@ namespace iqlogger::inputs::gelf::tcp {
start_accept();
}

boost::asio::io_service &m_io_service;
tcp::acceptor m_acceptor;
RecordQueuePtr<Gelf> m_queuePtr;
};
Expand Down
6 changes: 4 additions & 2 deletions src/inputs/json/tcp/Server.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ namespace iqlogger::inputs::json::tcp {
public:

explicit Server(RecordQueuePtr<Json> queuePtr, boost::asio::io_service &io_service, short port)
: m_acceptor(io_service, tcp::endpoint(tcp::v4(), port)),
: m_io_service(io_service),
m_acceptor(io_service, tcp::endpoint(tcp::v4(), port)),
m_queuePtr(queuePtr)
{
start_accept();
Expand All @@ -128,7 +129,7 @@ namespace iqlogger::inputs::json::tcp {
void start_accept()
{
tcp_connection::pointer new_connection =
tcp_connection::create(m_acceptor.get_io_service(), m_queuePtr);
tcp_connection::create(m_io_service, m_queuePtr);

auto handler = [this, new_connection](const boost::system::error_code &error) {
handle_accept(new_connection, error);
Expand All @@ -152,6 +153,7 @@ namespace iqlogger::inputs::json::tcp {
start_accept();
}

boost::asio::io_service &m_io_service;
tcp::acceptor m_acceptor;
RecordQueuePtr<Json> m_queuePtr;
};
Expand Down
4 changes: 2 additions & 2 deletions src/outputs/gelf/tcp/GelfOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ GelfOutput::GelfOutput(config::DestinationConfig destinationConfig, metrics::ato
}
};

auto connect = [&socket, &error, upstream, port = m_port, &run]() {
auto connect = [this, &socket, &error, upstream, port = m_port, &run]() {

DEBUG("Connect to " << upstream << ":" << port);

boost::asio::ip::tcp::resolver resolver(socket.get_io_service());
boost::asio::ip::tcp::resolver resolver(m_io_service);

try
{
Expand Down

0 comments on commit 8f26096

Please sign in to comment.