0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-04-14 09:38:34 +00:00
netdata_netdata/packaging/utils/compile-and-run-windows.sh
Costa Tsaousis d28b61ed56
detect netdata exit reasons ()
* detect netdata exit reasons

* log exit initiated

* commented debug logs

* commented debug logs again

* fix windows system shutdown detection

* commented debug logs again

* added exit reason msgid

* test shutdown detection by writing to exit.reason

* implement status file loading/saving

* accept also the shutdown event

* fix windows logs

* run as service from the script - not working yet

* save the first fatal message into the status file

* save memory information in the status file

* load machine guid early enough

* fix loading sequence

* simplify function run once logic; add dependencies on netdata.conf loading when required

* accept service parameter

* build for packaging is required for services

* log last exit status with a proper message; log node id and claim id in the status file

* added /var/cache disk space; fixed bug in rfc3339 parsing

* change log priority based on condition

* SIGINT is normal exit under windows

* wait to wevt provider to be initialized before logging

* Revert "fix windows logs ()"

This reverts commit d8c3dc087c.

* fix windows logs - the right way

* set default event log sizes

* added detection of netdata update

* added systemd dbus watcher for systemd shutdown/suspend events

* log system shutdown

* detect system reboot in a better way

* cleanup static thread

* on fatal, call _exit(); linunwind should not skip top calls on the stack

* make the sd bus watcher exit on netdata shutdown

* make the netdata agent version log also print the last exit status

* start watcher when shutdown is initiated; prevent double logging of shutdown initiation

* prepare for sending reports

* a single read per receiver

* track memory calls per worker

* use 4 malloc arenas on parents

* spread higher tiers flushing over time

* pgc and replication tuning

* on child disconnect, get retention from the rrdcontexts worker

* BUFFER: the default size is now 1024 bytes

* use dedicated jemalloc arena for judy allocations

* ARAL: do not double the page size unconditionally; cleanup old members

* double pgc partitions

* fix compiler warning

* make the default replication commit buffer big enough to avoid constant realloc

* post crash reports

* revert log2journal changes

* log2journal minor

* disable the crash report when there was no status file

* increase buffer sizes

* added os_boottime() and os_boot_id(), which are now used in the status file

* log2journal: convert \u000A to \n

* fix headers includes

* fix compilation on non-linux

* for host prefix when getting boot_id and boottime

* write status file to /run/netdata too

* fix /run/netdata on startup

* move the IPC pipe inside the run directory

* exclusive file lock to avoid running concurrently

* allow netdatacli to run from any user and still find the run dir of netdata

* fix pipe failure message

* fix nested loop sharing same variable in ADCS

* fix run_dir and netdatacli on windows

* fix status files on windows

* initialize nd_threads early enough to allow creating threads during initialization

* fix compiler warnings

* on shutdown ignore points with delayed flushing

* fix macos compilation

* added os_type to daemon status

* make daemon status schema ecs compatible

* save daemon status file on every signal

* fix external plugins log to journal

* use special allocators for judy, only on netdata - not the external plugins

* systemd-cat-native: default newline string is \n

* when generating json, prefer special 2 character sequences for common control characters

* fix daemon-status filenames

* log errors when the status file cannot be opened/saved/parsed

* make status file world readable

* do not write status file in /run/netdata; add fall back locations when the file cannot be saved in the cache dir

* move ram and disk into host

* simplified inline subobject parsing for jsonc

* ensure path is an array of at least 128 bytes

* fix non-linux compilation
2025-02-24 14:20:53 +02:00

131 lines
3.8 KiB
Bash

#!/bin/bash
RUN_AS_SERVICE=0
# On MSYS2, install these dependencies to build netdata:
install_dependencies() {
pacman -S \
git cmake ninja clang base-devel msys2-devel \
libyaml-devel libzstd-devel libutil-linux libutil-linux-devel \
mingw-w64-x86_64-toolchain mingw-w64-ucrt-x86_64-toolchain \
mingw64/mingw-w64-x86_64-mold ucrt64/mingw-w64-ucrt-x86_64-mold \
msys/gdb ucrt64/mingw-w64-ucrt-x86_64-gdb mingw64/mingw-w64-x86_64-gdb \
msys/zlib-devel mingw64/mingw-w64-x86_64-zlib ucrt64/mingw-w64-ucrt-x86_64-zlib \
msys/libuv-devel ucrt64/mingw-w64-ucrt-x86_64-libuv mingw64/mingw-w64-x86_64-libuv \
liblz4-devel mingw64/mingw-w64-x86_64-lz4 ucrt64/mingw-w64-ucrt-x86_64-lz4 \
openssl-devel mingw64/mingw-w64-x86_64-openssl ucrt64/mingw-w64-ucrt-x86_64-openssl \
protobuf-devel mingw64/mingw-w64-x86_64-protobuf ucrt64/mingw-w64-ucrt-x86_64-protobuf \
msys/pcre2-devel mingw64/mingw-w64-x86_64-pcre2 ucrt64/mingw-w64-ucrt-x86_64-pcre2 \
msys/brotli-devel mingw64/mingw-w64-x86_64-brotli ucrt64/mingw-w64-ucrt-x86_64-brotli \
msys/ccache ucrt64/mingw-w64-ucrt-x86_64-ccache mingw64/mingw-w64-x86_64-ccache \
mingw64/mingw-w64-x86_64-go ucrt64/mingw-w64-ucrt-x86_64-go \
mingw64/mingw-w64-x86_64-nsis \
msys/libcurl msys/libcurl-devel
}
BUILD_FOR_PACKAGING="Off"
if [ "${1}" = "install" ]
then
install_dependencies || exit 1
exit 0
fi
if [ "${1}" = "service" ]
then
RUN_AS_SERVICE=1
BUILD_FOR_PACKAGING="On"
shift
fi
if [ "${1}" = "package" ]
then
BUILD_FOR_PACKAGING="On"
fi
export PATH="/usr/local/bin:${PATH}"
WT_ROOT="$(pwd)"
BUILD_TYPE="Debug"
NULL=""
if [ -z "${MSYSTEM}" ]; then
build="${WT_ROOT}/build-${OSTYPE}"
else
build="${WT_ROOT}/build-${OSTYPE}-${MSYSTEM}"
fi
if [ "$USER" = "vk" ]; then
build="${WT_ROOT}/build"
fi
set -exu -o pipefail
if [ ! -d "${build}" ]
then
/usr/bin/cmake -S "${WT_ROOT}" -B "${build}" \
-G Ninja \
-DCMAKE_INSTALL_PREFIX="/opt/netdata" \
-DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \
-DCMAKE_C_FLAGS="-fstack-protector-all -O0 -ggdb -Wall -Wextra -Wno-char-subscripts -Wa,-mbig-obj -pipe -DNETDATA_INTERNAL_CHECKS=1 -D_FILE_OFFSET_BITS=64 -D__USE_MINGW_ANSI_STDIO=1" \
-DBUILD_FOR_PACKAGING=${BUILD_FOR_PACKAGING} \
-DUSE_MOLD=Off \
-DNETDATA_USER="${USER}" \
-DDEFAULT_FEATURE_STATE=Off \
-DENABLE_H2O=Off \
-DENABLE_ML=On \
-DENABLE_BUNDLED_JSONC=On \
-DENABLE_BUNDLED_PROTOBUF=Off \
-DENABLE_PLUGIN_APPS=On \
${NULL}
fi
echo "Compiling Netdata..."
ninja -v -C "${build}" || ninja -v -C "${build}" -j 1
echo "Stopping service Netdata..."
sc stop "Netdata" || echo "stop Failed, ok"
if [ $RUN_AS_SERVICE -eq 1 ]; then
sc delete "Netdata" || echo "delete Failed, ok"
fi
rm -f /opt/netdata/usr/bin/*.dll || echo "deleting old .dll files failed, ok"
ninja -v -C "${build}" install
# register the event log publisher
cmd.exe //c "$(cygpath -w -a "/opt/netdata/usr/bin/wevt_netdata_install.bat")"
#echo
#echo "Compile with:"
#echo "ninja -v -C \"${build}\" install || ninja -v -C \"${build}\" -j 1"
if [ $RUN_AS_SERVICE -eq 1 ]; then
echo
echo "Copying library files to /opt/netdata/usr/bin ..."
ldd /opt/netdata/usr/bin/netdata |\
grep " => /usr/bin/" |\
sed -e 's|\s\+| |g' -e 's|^ ||g' |\
cut -d ' ' -f 3 |\
while read x; do
cp $x /opt/netdata/usr/bin/
done
echo
echo "Registering Netdata service..."
sc create "Netdata" binPath= "$(cygpath.exe -w /opt/netdata/usr/bin/netdata.exe)" start= auto
echo "Starting Netdata service..."
sc start "Netdata"
else
echo "Starting netdata..."
# enable JIT debug with gdb
export MSYS="error_start:$(cygpath -w /usr/bin/gdb)"
rm -rf /opt/netdata/var/log/netdata/*.log || echo
/opt/netdata/usr/bin/netdata -D
fi