mirror of
https://github.com/badaix/snapcast.git
synced 2025-04-29 10:17:16 +02:00
Log revision (git sha)
This commit is contained in:
parent
2a1fde8ec7
commit
2c69844cad
8 changed files with 86 additions and 23 deletions
2
.github/workflows/macos.yml
vendored
2
.github/workflows/macos.yml
vendored
|
@ -30,6 +30,6 @@ jobs:
|
|||
#- name: ccache dump config
|
||||
# run: ccache -p
|
||||
- name: cmake build
|
||||
run: cmake -S . -B build -DBOOST_ROOT=boost_1_75_0 -DCMAKE_BUILD_TYPE=Release -DWERROR=ON -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_FLAGS="-I/usr/local/include"
|
||||
run: cmake -S . -B build -DBOOST_ROOT=boost_1_75_0 -DCMAKE_BUILD_TYPE=Release -DWERROR=ON -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DREVISION=${{ github.sha }} -DCMAKE_CXX_FLAGS="-I/usr/local/include"
|
||||
- name: cmake make
|
||||
run: cmake --build build --parallel 3
|
||||
|
|
6
.github/workflows/self-hosted.yml
vendored
6
.github/workflows/self-hosted.yml
vendored
|
@ -12,16 +12,16 @@ jobs:
|
|||
run: rm -rf /home/pi/actions-runner/_work/snapcast/snap*_armhf.deb
|
||||
- uses: actions/checkout@v2
|
||||
- name: cmake build
|
||||
run: mkdir build && cd build && cmake -DBOOST_ROOT=/home/pi/Develop/boost_1_75_0 -DCMAKE_BUILD_TYPE=Release -DWERROR=ON -DCMAKE_CXX_FLAGS="$CXXFLAGS -Wno-psabi" -DCMAKE_CXX_COMPILER_LAUNCHER=ccache .. && cd ..
|
||||
run: mkdir build && cd build && cmake -DBOOST_ROOT=/home/pi/Develop/boost_1_75_0 -DCMAKE_BUILD_TYPE=Release -DWERROR=ON -DCMAKE_CXX_FLAGS="$CXXFLAGS -Wno-psabi" -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DREVISION=${{ github.sha }} .. && cd ..
|
||||
- name: cmake make
|
||||
run: cmake --build build -- -j 2
|
||||
- name: debian package
|
||||
run: |
|
||||
fakeroot make -f debian/rules CMAKEFLAGS="-DBOOST_ROOT=/home/pi/Develop/boost_1_75_0 -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DBUILD_WITH_PULSE=OFF" binary
|
||||
fakeroot make -f debian/rules CMAKEFLAGS="-DBOOST_ROOT=/home/pi/Develop/boost_1_75_0 -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DREVISION=${{ github.sha }} -DBUILD_WITH_PULSE=OFF" binary
|
||||
rename 's/_armhf/_without-pulse_armhf/g' ../snapclient*_armhf.deb
|
||||
rm ../snapserver*_armhf.deb
|
||||
fakeroot make -f debian/rules clean
|
||||
fakeroot make -f debian/rules CMAKEFLAGS="-DBOOST_ROOT=/home/pi/Develop/boost_1_75_0 -DCMAKE_CXX_COMPILER_LAUNCHER=ccache" binary
|
||||
fakeroot make -f debian/rules CMAKEFLAGS="-DBOOST_ROOT=/home/pi/Develop/boost_1_75_0 -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DREVISION=${{ github.sha }}" binary
|
||||
- name: Archive artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
|
|
6
.github/workflows/ubuntu.yml
vendored
6
.github/workflows/ubuntu.yml
vendored
|
@ -31,16 +31,16 @@ jobs:
|
|||
#- name: ccache dump config
|
||||
# run: ccache -p
|
||||
- name: cmake build
|
||||
run: cmake -S . -B build -DBOOST_ROOT=boost_1_75_0 -DCMAKE_BUILD_TYPE=Release -DWERROR=ON -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||
run: cmake -S . -B build -DBOOST_ROOT=boost_1_75_0 -DCMAKE_BUILD_TYPE=Release -DWERROR=ON -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DREVISION=${{ github.sha }}
|
||||
- name: cmake make
|
||||
run: cmake --build build --parallel 3
|
||||
- name: debian package
|
||||
run: |
|
||||
fakeroot make -f debian/rules CMAKEFLAGS="-DBOOST_ROOT=boost_1_75_0 -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DBUILD_WITH_PULSE=OFF" binary
|
||||
fakeroot make -f debian/rules CMAKEFLAGS="-DBOOST_ROOT=boost_1_75_0 -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DREVISION=${{ github.sha }} -DBUILD_WITH_PULSE=OFF" binary
|
||||
rename 's/_amd64/_without-pulse_amd64/g' ../snapclient*_amd64.deb
|
||||
rm ../snapserver*_amd64.deb
|
||||
fakeroot make -f debian/rules clean
|
||||
fakeroot make -f debian/rules CMAKEFLAGS="-DBOOST_ROOT=boost_1_75_0 -DCMAKE_CXX_COMPILER_LAUNCHER=ccache" binary
|
||||
fakeroot make -f debian/rules CMAKEFLAGS="-DBOOST_ROOT=boost_1_75_0 -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DREVISION=${{ github.sha }}" binary
|
||||
- name: Archive artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
|
|
2
.github/workflows/windows.yml
vendored
2
.github/workflows/windows.yml
vendored
|
@ -22,7 +22,7 @@ jobs:
|
|||
- name: cmake build
|
||||
run: |
|
||||
echo vcpkg installation root: ${env:VCPKG_INSTALLATION_ROOT}
|
||||
cmake -S . -B build -G "Visual Studio 16 2019" -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET="x64-windows" -DCMAKE_BUILD_TYPE="Release" -DWERROR=ON
|
||||
cmake -S . -B build -G "Visual Studio 16 2019" -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET="x64-windows" -DCMAKE_BUILD_TYPE="Release" -DREVISION="${{ github.sha }}" -DWERROR=ON
|
||||
- name: cmake make
|
||||
run: cmake --build build --config Release --parallel 3 --verbose
|
||||
- name: installer
|
||||
|
|
|
@ -15,6 +15,10 @@ option(UBSAN "Enable UndefinedBehaviorSanitizer" OFF)
|
|||
|
||||
option(TIDY "Enable clang tidy" OFF)
|
||||
|
||||
IF (REVISION)
|
||||
add_compile_definitions(REVISION=\"${REVISION}\")
|
||||
ENDIF()
|
||||
|
||||
IF (TIDY)
|
||||
FIND_PROGRAM(CLANG_TIDY "clang-tidy")
|
||||
IF(CLANG_TIDY)
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "common/snap_exception.hpp"
|
||||
#include "common/str_compat.hpp"
|
||||
#include "common/utils.hpp"
|
||||
#include "common/version.hpp"
|
||||
#include "metadata.hpp"
|
||||
|
||||
|
||||
|
@ -55,6 +56,7 @@ using namespace std::chrono_literals;
|
|||
|
||||
static constexpr auto LOG_TAG = "Snapclient";
|
||||
|
||||
|
||||
PcmDevice getPcmDevice(const std::string& player, const std::string& parameter, const std::string& soundcard)
|
||||
{
|
||||
#if defined(HAS_ALSA) || defined(HAS_PULSE) || defined(HAS_WASAPI)
|
||||
|
@ -195,7 +197,7 @@ int main(int argc, char** argv)
|
|||
|
||||
if (versionSwitch->is_set())
|
||||
{
|
||||
cout << "snapclient v" << VERSION << "\n"
|
||||
cout << "snapclient v" << version::code << (!version::rev().empty() ? (" (rev " + version::rev(8) + ")") : ("")) << "\n"
|
||||
<< "Copyright (C) 2014-2021 BadAix (snapcast@badaix.de).\n"
|
||||
<< "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\n"
|
||||
<< "This is free software: you are free to change and redistribute it.\n"
|
||||
|
@ -419,6 +421,8 @@ int main(int argc, char** argv)
|
|||
io_context.stop();
|
||||
});
|
||||
|
||||
LOG(INFO, LOG_TAG) << "Snapclient v" << version::code << (!version::rev().empty() ? (", revision " + version::rev(8)) : ("")) << " started\n";
|
||||
|
||||
// Setup metadata handling
|
||||
auto meta(metaStderr ? std::make_unique<MetaStderrAdapter>() : std::make_unique<MetadataAdapter>());
|
||||
auto controller = make_shared<Controller>(io_context, settings, std::move(meta));
|
||||
|
|
50
common/version.hpp
Normal file
50
common/version.hpp
Normal file
|
@ -0,0 +1,50 @@
|
|||
/***
|
||||
This file is part of snapcast
|
||||
Copyright (C) 2014-2021 Johannes Pohl
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#ifndef VERSION_HPP
|
||||
#define VERSION_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace version
|
||||
{
|
||||
|
||||
#ifdef REVISION
|
||||
static constexpr auto revision = REVISION;
|
||||
#else
|
||||
static constexpr auto revision = "";
|
||||
#endif
|
||||
|
||||
#ifdef VERSION
|
||||
static constexpr auto code = VERSION;
|
||||
#else
|
||||
static constexpr auto code = "";
|
||||
#endif
|
||||
|
||||
static std::string rev(std::size_t len = 0)
|
||||
{
|
||||
if (len == 0)
|
||||
{
|
||||
return revision;
|
||||
}
|
||||
return std::string(revision).substr(0, len);
|
||||
}
|
||||
|
||||
} // namespace version
|
||||
|
||||
#endif
|
|
@ -28,6 +28,7 @@
|
|||
#include "common/snap_exception.hpp"
|
||||
#include "common/time_defs.hpp"
|
||||
#include "common/utils/string_utils.hpp"
|
||||
#include "common/version.hpp"
|
||||
#include "encoder/encoder_factory.hpp"
|
||||
#include "message/message.hpp"
|
||||
#include "server.hpp"
|
||||
|
@ -42,6 +43,8 @@
|
|||
using namespace std;
|
||||
using namespace popl;
|
||||
|
||||
static constexpr auto LOG_TAG = "Snapserver";
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
@ -149,7 +152,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
if (versionSwitch->is_set())
|
||||
{
|
||||
cout << "snapserver v" << VERSION << "\n"
|
||||
cout << "snapserver v" << version::code << (!version::rev().empty() ? (" (rev " + version::rev(8) + ")") : ("")) << "\n"
|
||||
<< "Copyright (C) 2014-2021 BadAix (snapcast@badaix.de).\n"
|
||||
<< "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\n"
|
||||
<< "This is free software: you are free to change and redistribute it.\n"
|
||||
|
@ -223,17 +226,19 @@ int main(int argc, char* argv[])
|
|||
else
|
||||
throw SnapException("Invalid log sink: " + settings.logging.sink);
|
||||
|
||||
LOG(INFO, LOG_TAG) << "Snapserver v" << version::code << (!version::rev().empty() ? (", revision " + version::rev(8)) : ("")) << " started\n";
|
||||
|
||||
if (!streamValue->is_set() && !sourceValue->is_set())
|
||||
settings.stream.sources.push_back(sourceValue->value());
|
||||
|
||||
for (size_t n = 0; n < streamValue->count(); ++n)
|
||||
{
|
||||
LOG(INFO) << "Adding stream: " << streamValue->value(n) << "\n";
|
||||
LOG(INFO, LOG_TAG) << "Adding stream: " << streamValue->value(n) << "\n";
|
||||
settings.stream.sources.push_back(streamValue->value(n));
|
||||
}
|
||||
for (size_t n = 0; n < sourceValue->count(); ++n)
|
||||
{
|
||||
LOG(INFO) << "Adding source: " << sourceValue->value(n) << "\n";
|
||||
LOG(INFO, LOG_TAG) << "Adding source: " << sourceValue->value(n) << "\n";
|
||||
settings.stream.sources.push_back(sourceValue->value(n));
|
||||
}
|
||||
|
||||
|
@ -252,9 +257,9 @@ int main(int argc, char* argv[])
|
|||
processPriority = std::min(std::max(-20, processPriority), 19);
|
||||
if (processPriority != 0)
|
||||
setpriority(PRIO_PROCESS, 0, processPriority);
|
||||
LOG(NOTICE) << "daemonizing" << std::endl;
|
||||
LOG(NOTICE, LOG_TAG) << "daemonizing" << std::endl;
|
||||
daemon->daemonize();
|
||||
LOG(NOTICE) << "daemon started" << std::endl;
|
||||
LOG(NOTICE, LOG_TAG) << "daemon started" << std::endl;
|
||||
}
|
||||
else
|
||||
Config::instance().init(settings.server.data_dir);
|
||||
|
@ -281,13 +286,13 @@ int main(int argc, char* argv[])
|
|||
#endif
|
||||
if (settings.stream.streamChunkMs < 10)
|
||||
{
|
||||
LOG(WARNING) << "Stream read chunk size is less than 10ms, changing to 10ms\n";
|
||||
LOG(WARNING, LOG_TAG) << "Stream read chunk size is less than 10ms, changing to 10ms\n";
|
||||
settings.stream.streamChunkMs = 10;
|
||||
}
|
||||
|
||||
if (settings.stream.bufferMs < 400)
|
||||
{
|
||||
LOG(WARNING) << "Buffer is less than 400ms, changing to 400ms\n";
|
||||
LOG(WARNING, LOG_TAG) << "Buffer is less than 400ms, changing to 400ms\n";
|
||||
settings.stream.bufferMs = 400;
|
||||
}
|
||||
|
||||
|
@ -296,15 +301,15 @@ int main(int argc, char* argv[])
|
|||
|
||||
if (settings.server.threads < 0)
|
||||
settings.server.threads = std::max(2, std::min(4, static_cast<int>(std::thread::hardware_concurrency())));
|
||||
LOG(INFO) << "number of threads: " << settings.server.threads << ", hw threads: " << std::thread::hardware_concurrency() << "\n";
|
||||
LOG(INFO, LOG_TAG) << "Number of threads: " << settings.server.threads << ", hw threads: " << std::thread::hardware_concurrency() << "\n";
|
||||
|
||||
// Construct a signal set registered for process termination.
|
||||
boost::asio::signal_set signals(io_context, SIGHUP, SIGINT, SIGTERM);
|
||||
signals.async_wait([&io_context](const boost::system::error_code& ec, int signal) {
|
||||
if (!ec)
|
||||
LOG(INFO) << "Received signal " << signal << ": " << strsignal(signal) << "\n";
|
||||
LOG(INFO, LOG_TAG) << "Received signal " << signal << ": " << strsignal(signal) << "\n";
|
||||
else
|
||||
LOG(INFO) << "Failed to wait for signal, error: " << ec.message() << "\n";
|
||||
LOG(INFO, LOG_TAG) << "Failed to wait for signal, error: " << ec.message() << "\n";
|
||||
io_context.stop();
|
||||
});
|
||||
|
||||
|
@ -317,16 +322,16 @@ int main(int argc, char* argv[])
|
|||
for (auto& t : threads)
|
||||
t.join();
|
||||
|
||||
LOG(INFO) << "Stopping streamServer" << endl;
|
||||
LOG(INFO, LOG_TAG) << "Stopping streamServer" << endl;
|
||||
server->stop();
|
||||
LOG(INFO) << "done" << endl;
|
||||
LOG(INFO, LOG_TAG) << "done" << endl;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
LOG(ERROR) << "Exception: " << e.what() << std::endl;
|
||||
LOG(ERROR, LOG_TAG) << "Exception: " << e.what() << std::endl;
|
||||
exitcode = EXIT_FAILURE;
|
||||
}
|
||||
Config::instance().save();
|
||||
LOG(NOTICE) << "Snapserver terminated." << endl;
|
||||
LOG(NOTICE, LOG_TAG) << "Snapserver terminated." << endl;
|
||||
exit(exitcode);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue