From d9c260e3e68de16cb8f3c3a087172eb308852c61 Mon Sep 17 00:00:00 2001 From: Frederico Araujo Date: Tue, 4 Feb 2020 04:55:28 +0000 Subject: [PATCH] Completes port of collector image to RHEL UBI8; fixes and improves build for modules and collector; added hooks for multi-stage builds with intermediate stage caching; Closes sysflow-telemetry/sf-docs#20 --- Dockerfile.collector.amd64 | 130 +++++++++++++++++++++++-------------- Dockerfile.ubi.amd64 | 85 +++++++++++++++++------- hooks/build | 19 ++++++ hooks/post_push | 8 +++ hooks/pre_build | 8 +++ hooks/pre_test | 4 +- makefile.env.inc | 7 +- modules/Makefile | 29 +++++++-- src/Makefile | 25 ++++--- src/main.cpp | 16 ++--- 10 files changed, 231 insertions(+), 100 deletions(-) create mode 100644 hooks/post_push create mode 100644 hooks/pre_build diff --git a/Dockerfile.collector.amd64 b/Dockerfile.collector.amd64 index 72458a48..c5432d50 100644 --- a/Dockerfile.collector.amd64 +++ b/Dockerfile.collector.amd64 @@ -17,35 +17,48 @@ # See the License for the specific language governing permissions and # limitations under the License. +ARG TAG=latest #----------------------- # Stage: builder #----------------------- -FROM sfcollector-ubi:latest AS builder +FROM sysflowtelemetry/sf-collector:${TAG}-mods AS builder -ENV LIBRARY_PATH=/lib64 -ARG gllogtostderr=1 -ENV GLOG_logtostderr=$gllogtostderr +# environment and build args +ARG BUILD_NUMBER=0 -ARG glv= -ENV GLOG_v=$glv +ARG INSTALL_PATH=/usr/local/sysflow -ARG BUILD_NUMBER=0 +ARG MODPREFIX=${INSTALL_PATH}/modules -## build sysporter +ENV LIBRARY_PATH=/lib64 + +# build sysporter COPY ./src/ /build/src/ -RUN cd /build/src && make SYSFLOW_BUILD_NUMBER=$BUILD_NUMBER +RUN cd /build/src && \ + make SYSFLOW_BUILD_NUMBER=$BUILD_NUMBER \ + LIBLOCALPREFIX=${MODPREFIX} \ + SDLOCALLIBPREFIX=${MODPREFIX}/lib \ + SDLOCALINCPREFIX=${MODPREFIX}/include/sysdig \ + AVRLOCALLIBPREFIX=${MODPREFIX}/lib \ + AVRLOCALINCPREFIX=${MODPREFIX}/include \ + SFLOCALINCPREFIX=${MODPREFIX}/include/sysflow/c++ \ + FSLOCALINCPREFIX=${MODPREFIX}/include/filesystem \ + SCHLOCALPREFIX=${MODPREFIX}/conf \ + install && \ + make clean && \ + rm -rf /build -##----------------------- -## Stage: Runtime -##----------------------- -FROM sfcollector-ubi:latest as runtime +#----------------------- +# Stage: Runtime +#----------------------- +FROM sysflowtelemetry/sf-collector:base-${TAG} AS runtime -## environment variables +# environment variables ARG interval=30 ENV INTERVAL=$interval -ARG filter="" +ARG filter= ENV FILTER=$filter ARG exporterid="local" @@ -54,55 +67,78 @@ ENV EXPORTER_ID=$exporterid ARG output=/mnt/data/ ENV OUTPUT=$output -## copy dependencies -COPY --from=builder /build/src/sysporter /usr/local/sysflow/bin/ -COPY --from=builder /build/modules/sysflow/avro/avsc/SysFlow.avsc /usr/local/sysflow/conf/ -RUN ln -s /usr/local/sysflow/modules/lib/libcrypto.so /usr/local/sysflow/modules/lib/libcrypto.so.1.0.0 -RUN ln -s /usr/local/sysflow/modules/lib/libssl.so /usr/local/sysflow/modules/lib/libssl.so.1.0.0 +ARG cripath= +ENV CRI_PATH=$cripath + +ARG critimeout= +ENV CRI_TIMEOUT=$critimeout + +ARG debug= +ENV DEBUG=$debug + +ARG gllogtostderr=1 +ENV GLOG_logtostderr=$gllogtostderr + +ARG glv= +ENV GLOG_v=$glv + +ARG INSTALL_PATH=/usr/local/sysflow + +ARG MODPREFIX=${INSTALL_PATH}/modules -## entrypoint +# copy dependencies +COPY --from=builder /usr/local/lib/ /usr/local/lib/ +COPY --from=builder ${MODPREFIX}/lib/*.so* ${MODPREFIX}/lib/ +COPY --from=builder ${MODPREFIX}/bin/sysdig-probe-loader ${MODPREFIX}/bin/ +RUN ln -s ${INSTALL_PATH}/bin/sysdig-probe-loader /usr/bin/sysdig-probe-loader +COPY --from=builder ${INSTALL_PATH}/conf/ ${INSTALL_PATH}/conf/ +COPY --from=builder ${INSTALL_PATH}/bin/sysporter ${INSTALL_PATH}/bin/ + +# entrypoint WORKDIR /usr/local/sysflow/bin/ -CMD /usr/local/sysflow/bin/sysporter -G $INTERVAL -w $OUTPUT -e "$EXPORTER_ID" -f "$FILTER" -##----------------------- -## Stage: Testing -##----------------------- -FROM runtime as testing +CMD /usr/local/sysflow/bin/sysporter \ + ${INTERVAL:+-G} $INTERVAL \ + ${OUTPUT:+-w} $OUTPUT \ + ${EXPORTER_ID:+-e} "$EXPORTER_ID" \ + ${FILTER:+-f} "$FILTER" \ + ${CRI_PATH:+-p} ${CRI_PATH} \ + ${CRI_TIMEOUT:+-t} ${CRI_TIMEOUT} \ + ${DEBUG:+-d} + +#----------------------- +# Stage: Testing +#----------------------- +FROM runtime AS testing + +# environment and build args +ARG BATS_VERSION=1.1.0 ARG wdir=/usr/local/sysflow ENV WDIR=$wdir -## dependencies -# Install Python environment +ARG INSTALL_PATH=/usr/local/sysflow + +# dependencies RUN dnf install -y --disableplugin=subscription-manager \ - python3 \ + python3 \ python3-wheel && \ mkdir -p /usr/local/lib/python3.6/site-packages && \ ln -s /usr/bin/easy_install-3 /usr/bin/easy_install && \ ln -s /usr/bin/python3 /usr/bin/python && \ ln -s /usr/bin/pip3 /usr/bin/pip && \ dnf -y clean all && rm -rf /var/cache/dnf -#RUN apt-get update -yqq && \ -# apt-get --no-install-recommends --fix-broken install -yqq && \ -# apt-get install -yqq \ -# apt-utils \ -# git \ -# locales \ -# valgrind \ -# python3 \ -# python3-pip && \ -# locale-gen en_US.UTF-8 && \ -# apt-get clean -yqq && \ -# rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /var/lib/apt/archive/* - -## copy dependencies -COPY --from=builder /build/modules/sysflow/py3 /usr/local/sysflow/utils/ + +RUN mkdir /tmp/bats && cd /tmp/bats && \ + wget https://github.com/bats-core/bats-core/archive/v${BATS_VERSION}.tar.gz && \ + tar -xzf v${BATS_VERSION}.tar.gz && rm -rf v${BATS_VERSION}.tar.gz && \ + cd bats-core-${BATS_VERSION} && ./install.sh /usr/local && rm -rf /tmp/bats + +# install APIs +COPY modules/sysflow/py3 ${INSTALL_PATH}/utils RUN cd /usr/local/sysflow/utils && \ python3 setup.py install -RUN mkdir /bats && git clone https://github.com/bats-core/bats-core.git /bats && \ - cd /bats && ./install.sh /usr/local && rm -r /bats - WORKDIR $wdir ENTRYPOINT ["/usr/local/bin/bats"] diff --git a/Dockerfile.ubi.amd64 b/Dockerfile.ubi.amd64 index f7a35653..aa7e0665 100644 --- a/Dockerfile.ubi.amd64 +++ b/Dockerfile.ubi.amd64 @@ -18,40 +18,75 @@ # limitations under the License. #----------------------- -# Stage: deps +# Stage: base #----------------------- -FROM registry.access.redhat.com/ubi8/ubi:latest AS deps +FROM registry.access.redhat.com/ubi8/ubi AS base -ENV LIBRARY_PATH=/lib64 +# dependencies +RUN dnf install -y --disableplugin=subscription-manager \ + http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/centos-gpg-keys-8.1-1.1911.0.8.el8.noarch.rpm \ + http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/centos-repos-8.1-1.1911.0.8.el8.x86_64.rpm && \ + dnf update -y --disableplugin=subscription-manager && \ + dnf install -y --disableplugin=subscription-manager --disableexcludes=all --enablerepo=PowerTools \ + kernel-devel \ + kernel-headers \ + gcc \ + gcc-c++ \ + make \ + cmake \ + lua-devel \ + pkgconfig \ + autoconf \ + wget \ + automake \ + libtool \ + patch \ + binutils \ + bzip2 \ + perl \ + flex \ + bison \ + libstdc++-static \ + glibc-static \ + diffutils \ + kmod \ + epel-release \ + xz \ + boost-devel \ + elfutils-libelf-devel \ + apr-devel \ + apr-util-devel \ + sparsehash-devel \ + ncurses-devel \ + openssl-devel \ + glog-devel && \ + dnf update -y --disableplugin=subscription-manager && \ + dnf install -y --disableplugin=subscription-manager --disableexcludes=all --enablerepo=PowerTools dkms && \ + dnf -y clean all && rm -rf /var/cache/dnf -ENV SYSDIG_HOST_ROOT=/host +#----------------------- +# Stage: mods +#----------------------- +FROM base AS mods -ENV PATH="$PATH:/usr/local/sysflow/modules/bin" +# environment and args +ARG INSTALL_PATH=/usr/local/sysflow -ENV HOME=/root +ENV PATH="$PATH:"${INSTALL_PATH}"/modules/bin" -ARG gllogtostderr=1 -ENV GLOG_logtostderr=$gllogtostderr - -ARG glv= -ENV GLOG_v=$glv +ENV LIBRARY_PATH=/lib64 -## dependencies -ARG INSTALL_PKGS="kernel-devel kernel-headers gcc gcc-c++ make cmake lua-devel pkgconfig autoconf wget automake libtool patch binutils bzip2 perl make flex bison libstdc++-static glibc-static diffutils kmod epel-release" -RUN dnf install -y --disableplugin=subscription-manager http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/centos-gpg-keys-8.1-1.1911.0.8.el8.noarch.rpm http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/centos-repos-8.1-1.1911.0.8.el8.x86_64.rpm && \ - dnf update -y --disableplugin=subscription-manager && \ - dnf install -y --disableplugin=subscription-manager --disableexcludes=all --enablerepo=PowerTools ${INSTALL_PKGS} \ - xz boost-devel elfutils-libelf-devel apr-devel apr-util apr-util-devel sparsehash-devel ncurses-devel openssl-devel glog-devel && \ - dnf update -y --disableplugin=subscription-manager && \ - dnf install -y --disableplugin=subscription-manager --disableexcludes=all --enablerepo=PowerTools dkms +ENV SYSDIG_HOST_ROOT=/host +ENV HOME=/root -## build dependencies -#RUN mkdir /build -COPY ./modules /build/modules -COPY ./makefile.* /build/ -RUN cd /build/modules && make install +# build modules +COPY ./modules /build/modules +COPY ./makefile.* /build/ COPY ./docker-entry-ubi.sh /usr/local/sysflow/modules/bin/ -RUN cp /usr/local/sysflow/modules/bin/sysdig-probe-loader /usr/bin/ +RUN cd /build/modules && \ + make INSTALL_PATH=${INSTALL_PATH} install && \ + ln -s ${INSTALL_PATH}/bin/sysdig-probe-loader /usr/bin/sysdig-probe-loader && \ + make clean && rm -rf /build/modules ENTRYPOINT ["/usr/local/sysflow/modules/bin/docker-entry-ubi.sh"] diff --git a/hooks/build b/hooks/build index 9b73525d..78a887ed 100644 --- a/hooks/build +++ b/hooks/build @@ -6,7 +6,26 @@ echo "[***] Build hook running" make -C modules init # Multi-stage build +docker build \ + --cache-from $IMAGE_NAME-base \ + --target base \ + -f Dockerfile.ubi.amd64 \ + -t $IMAGE_NAME-base . + +docker build \ + --cache-from $IMAGE_NAME-mods \ + --target mods \ + -f Dockerfile.ubi.amd64 \ + -t $IMAGE_NAME-mods . + +docker build \ + --build-arg TAG=$DOCKER_TAG \ + --cache-from $IMAGE_NAME-builder \ + --target builder \ + -t $IMAGE_NAME-builder . + docker build \ --build-arg BUILD_NUMBER=$(git rev-parse --short HEAD) \ + --cache-from $IMAGE_NAME \ --target runtime \ -t $IMAGE_NAME . diff --git a/hooks/post_push b/hooks/post_push new file mode 100644 index 00000000..043fff0e --- /dev/null +++ b/hooks/post_push @@ -0,0 +1,8 @@ +#!/bin/bash + +echo "[***] Post-push hook running" + +docker push $IMAGE_NAME-base +docker push $IMAGE_NAME-mods +docker push $IMAGE_NAME-builder +docker push $IMAGE_NAME-testing diff --git a/hooks/pre_build b/hooks/pre_build new file mode 100644 index 00000000..d411a260 --- /dev/null +++ b/hooks/pre_build @@ -0,0 +1,8 @@ +#!/bin/bash + +echo "[***] Pre-build hook running" + +docker pull $IMAGE_NAME-base +docker pull $IMAGE_NAME-mods +docker pull $IMAGE_NAME-builder +docker pull $IMAGE_NAME diff --git a/hooks/pre_test b/hooks/pre_test index 7a88310a..dff99100 100644 --- a/hooks/pre_test +++ b/hooks/pre_test @@ -3,7 +3,9 @@ echo "[***] Pre-test hook running" # Build test container +docker pull $IMAGE_NAME-testing + docker build \ - --cache-from $IMAGE_NAME \ + --cache-from $IMAGE_NAME-testing \ --target testing \ -t $IMAGE_NAME-testing . diff --git a/makefile.env.inc b/makefile.env.inc index b03e43fd..14f48431 100644 --- a/makefile.env.inc +++ b/makefile.env.inc @@ -17,10 +17,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -PREFIX=/usr/local/sysflow -MODPREFIX=$(PREFIX)/modules +INSTALL_PATH?=/usr/local/sysflow +MODPREFIX=$(INSTALL_PATH)/modules LIBPREFIX=$(MODPREFIX)/lib BINPREFIX=$(MODPREFIX)/bin +CONFPREFIX=$(MODPREFIX)/conf DRIVERPREFIX=/usr/src/sysdig- SDINCPREFIX=$(MODPREFIX)/include/sysdig AVRINCPREFIX=$(MODPREFIX)/include/avro +SFINCPREFIX=$(MODPREFIX)/include/sysflow +FSINCPREFIX=$(MODPREFIX)/include/filesystem diff --git a/modules/Makefile b/modules/Makefile index 5ebf749c..5cee45f4 100644 --- a/modules/Makefile +++ b/modules/Makefile @@ -19,7 +19,7 @@ include ../makefile.manifest.inc include ../makefile.env.inc - + .PHONY: all all: init \ modules @@ -37,7 +37,9 @@ modules: sysdig/package \ .PHONY: install install: modules \ sysdig/install \ - avro/install + avro/install \ + sysflow/install \ + fs/install .PHONY: sysdig/package sysdig/package: @@ -71,15 +73,17 @@ sysdig/package: cp curl-prefix/src/curl/lib/.libs/libcurl.a lib/ && \ cp jq-prefix/src/jq/.libs/libjq.a lib/ && \ cp tbb-prefix/src/tbb/build/lib_release/libtbb.a lib/ && \ - cp openssl-prefix/src/openssl/libcrypto.so.1.0.0 lib/libcrypto.so && \ - cp openssl-prefix/src/openssl/libssl.so.1.0.0 lib/libssl.so && \ + cp openssl-prefix/src/openssl/libcrypto.so.1.0.0 lib/libcrypto.so.1.0.0 && \ + cd lib && ln -s libcrypto.so.1.0.0 libcrypto.so && cd .. && \ + cp openssl-prefix/src/openssl/libssl.so.1.0.0 lib/libssl.so.1.0.0 && \ + cd lib && ln -s libssl.so.1.0.0 libssl.so && cd .. && \ cp protobuf-prefix/src/protobuf/src/.libs/* lib && \ cp zlib-prefix/src/zlib/libz.so.1.2.11 lib/libz.so .PHONY: sysdig/install sysdig/install: mkdir -p $(SDINCPREFIX) && mkdir -p $(LIBPREFIX) && mkdir -p $(BINPREFIX) && mkdir -p "$(DRIVERPREFIX)$(SYSDIG_VERSION)" && \ - cd sysdig/build && cp -r include/* $(SDINCPREFIX)/ && cp -r lib/* $(LIBPREFIX)/ && cp -r bin/* $(BINPREFIX)/ && cp -r driver/src/* "$(DRIVERPREFIX)$(SYSDIG_VERSION)" + cd sysdig/build && cp -r include/* $(SDINCPREFIX)/ && cp -a lib/* $(LIBPREFIX)/ && cp -a bin/* $(BINPREFIX)/ && cp -a driver/src/* "$(DRIVERPREFIX)$(SYSDIG_VERSION)" .PHONY: avro/package avro/package: @@ -87,15 +91,26 @@ avro/package: cmake -DCMAKE_INSTALL_PREFIX=$(MODPREFIX) \ -DCMAKE_CXX_FLAGS_ALL_WARNINGS:STRING="-w" \ -DCMAKE_BUILD_TYPE=ALL_WARNINGS -G "Unix Makefiles" ../. && make && \ - cp -r ../api avro + cp -a ../api avro .PHONY: avro/install avro/install: cd avro/lang/c++/build && make install +.PHONY: sysflow/install +sysflow/install: + mkdir -p $(CONFPREFIX) && cp sysflow/avro/avsc/SysFlow.avsc $(CONFPREFIX)/ && \ + mkdir -p $(SFINCPREFIX)/c++/sysflow && cp -r sysflow/c++/sysflow/* $(SFINCPREFIX)/c++/sysflow/ + +.PHONY: fs/install +fs/install: + mkdir -p $(FSINCPREFIX) && cp -r filesystem/include/* $(FSINCPREFIX)/ + .PHONY: uninstall uninstall: - rm -rf $(PREFIX)/libs + rm -rf $(LIBPREFIX) $(INCPREFIX) $(CONFPREFIX) && \ + rm -rf $(DRIVERPREFIX)$(SYSDIG_VERSION) && \ + find $(BINPREFIX) ! -name "sysporter" -type f -exec rm -f {} + .PHONY: clean clean: diff --git a/src/Makefile b/src/Makefile index b3a14c75..7bc2d0c7 100644 --- a/src/Makefile +++ b/src/Makefile @@ -24,6 +24,7 @@ include ../makefile.env.inc # Target configuration TARGET = sysporter +SYSFLOW_BUILD_NUMBER ?= 0 # Lint options LINT = clang-tidy-9 @@ -37,11 +38,15 @@ LINTSRCS := $(filter-out MurmurHash3.cpp, $(wildcard *.cpp)) LINTHEADERS = "^($(shell pwd)\/)((?!logger).)*" # Dir structure configuration -LIBLOCALPREFIX = ../modules -SDLOCALLIBPREFIX = $(LIBLOCALPREFIX)/sysdig/build/lib -SDLOCALINCPREFIX = $(LIBLOCALPREFIX)/sysdig/build/include -AVRLOCALLIBPREFIX = $(LIBLOCALPREFIX)/avro/lang/c++/build -AVRLOCALINCPREFIX = $(LIBLOCALPREFIX)/avro/lang/c++/build +LIBLOCALPREFIX ?= ../modules +SDLOCALLIBPREFIX ?= $(LIBLOCALPREFIX)/sysdig/build/lib +SDLOCALINCPREFIX ?= $(LIBLOCALPREFIX)/sysdig/build/include +AVRLOCALLIBPREFIX ?= $(LIBLOCALPREFIX)/avro/lang/c++/build +AVRLOCALINCPREFIX ?= $(LIBLOCALPREFIX)/avro/lang/c++/build +SFLOCALINCPREFIX ?= $(LIBLOCALPREFIX)/sysflow/c++ +FSLOCALINCPREFIX ?= $(LIBLOCALPREFIX)/filesystem/include +SCHLOCALPREFIX ?= $(LIBLOCALPREFIX)/sysflow/avro/avsc + # Compiler options CXX = g++ @@ -50,7 +55,7 @@ LIBS = $(SDLOCALLIBPREFIX)/libsinsp.a $(SDLOCALLIBPREFIX)/libscap.a $(SDLOCALLIB -lstdc++ -lelf -lz -lrt -lanl -lssl -lcrypto -lpthread -lm -lavrocpp -lglog -ldl LDFLAGS = $(LIBS) -L/usr/local/lib/ -L$(LIBPREFIX)/ -L$(SDLOCALLIBPREFIX)/ -L$(AVRLOCALLIBPREFIX)/ \ -Wl,-rpath=/usr/local/lib -Wl,-rpath=$(LIBPREFIX) -Wl,-rpath=$(SDLOCALLIBPREFIX) -Wl,-rpath=$(AVRLOCALLIBPREFIX) -CFLAGS = -std=c++11 -Wall -ggdb -I.. -I../modules/sysflow/c++/ -I../modules/filesystem/include/ \ +CFLAGS = -std=c++11 -Wall -ggdb -I.. -I$(SFLOCALINCPREFIX)/ -I$(FSLOCALINCPREFIX)/ \ -DHAS_CAPTURE -DPLATFORM_NAME=\"Linux\" -DK8S_DISABLE_THREAD \ -I$(SDLOCALINCPREFIX)/ -I$(SDLOCALINCPREFIX)/curl/ -I$(SDLOCALINCPREFIX)/json/ -I$(SDLOCALINCPREFIX)/openssl/ -I$(SDLOCALINCPREFIX)/driver/ \ -I$(SDLOCALINCPREFIX)/userspace/libsinsp/ -I$(SDLOCALINCPREFIX)/userspace/libscap/ -I$(AVRLOCALINCPREFIX)/ -I/usr/local/include/ @@ -60,13 +65,13 @@ all: version $(TARGET) .PHONY: install install: all - mkdir -p $(PREFIX)/bin && cp sysporter $(PREFIX)/bin - mkdir -p $(PREFIX)/conf && cp avro/avsc/SysFlow.avsc $(PREFIX)/conf && cp conf/log4cxx.properties $(PREFIX)/conf + mkdir -p $(INSTALL_PATH)/bin && cp sysporter $(INSTALL_PATH)/bin + mkdir -p $(INSTALL_PATH)/conf && cp $(SCHLOCALPREFIX)/SysFlow.avsc $(INSTALL_PATH)/conf .PHONY: uninstall uninstall: - rm -rf $(PREFIX)/bin - rm -rf $(PREFIX)/conf + rm -rf $(INSTALL_PATH)/bin + rm -rf $(INSTALL_PATH)/conf .PHONY: lint lint: $(LINTSRCS) diff --git a/src/main.cpp b/src/main.cpp index c326e508..ebad413b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -192,7 +192,7 @@ int main(int argc, char **argv) { } else { fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt); } - return 1; + exit(1); default: abort(); } @@ -212,9 +212,9 @@ int main(int argc, char **argv) { return 1; } - //try { + try { CONFIGURE_LOGGER(logProps); - SF_DEBUG(logger, "Starting sysporter.."); + SF_DEBUG(logger, "Starting sysporter..."); auto *cxt = new context::SysFlowContext(filterCont, fileDuration, outputDir, scapFile, schemaFile, exporterID, filter, criPath, criTO); @@ -228,9 +228,9 @@ int main(int argc, char **argv) { int ret = s_prc->run(); delete s_prc; return ret; - /*} - CATCH_LOGGER_EXCEPTION() - catch(...) { - SF_ERROR(logger, "Unexcepted exception in main loop."); - }*/ + } + catch (sinsp_exception &ex) { + SF_ERROR(logger, "Runtime exception caught in main loop: " << ex.what()); + return 1; + } }