Index: head/net-mgmt/netdata/Makefile =================================================================== --- head/net-mgmt/netdata/Makefile (revision 530692) +++ head/net-mgmt/netdata/Makefile (revision 530693) @@ -1,111 +1,111 @@ # Created by: Mahdi Mokhtari # $FreeBSD$ PORTNAME= netdata PORTVERSION= 1.20.0 -PORTREVISION= 2 +PORTREVISION= 3 DISTVERSIONPREFIX= v CATEGORIES= net-mgmt MAINTAINER= mmokhi@FreeBSD.org COMMENT= Scalable distributed realtime performance and health monitoring LICENSE= GPLv3 LIB_DEPENDS= libuuid.so:misc/e2fsprogs-libuuid RUN_DEPENDS= bash:shells/bash \ curl:ftp/curl \ ${PYTHON_PKGNAMEPREFIX}yaml>0:devel/py-yaml@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}urllib3>0:net/py-urllib3@${PY_FLAVOR} USES= autoreconf cpe pathfix pkgconfig:both python shebangfix ssl USE_GITHUB= yes SHEBANG_GLOB= * NETDATA_CACHE= /var/cache/${PORTNAME} NETDATA_LOG= /var/log/${PORTNAME} NETDATA_PERST= /var/db/${PORTNAME} GNU_CONFIGURE= yes CONFIGURE_ARGS= --disable-unit-tests CPPFLAGS+= -D_WANT_VMMETER INSTALL_TARGET= install-strip SUB_LIST= NETDATA_CACHE=${NETDATA_CACHE} \ NETDATA_LOG=${NETDATA_LOG} \ NETDATA_PERST=${NETDATA_PERST} PLIST_SUB= NETDATA_CACHE=${NETDATA_CACHE} \ NETDATA_LOG=${NETDATA_LOG} \ NETDATA_PERST=${NETDATA_PERST} USE_RC_SUBR= ${PORTNAME} SUB_FILES= ${PORTNAME}.conf.sample USERS= netdata GROUPS= netdata OPTIONS_DEFINE= CUPS DBENGINE FREEIPMI GOPLUGIN JSON LTO OPTIONS_SUB= YES OPTIONS_DEFAULT= DBENGINE JSON OPTIONS_DEFAULT_FreeBSD_12= LTO OPTIONS_DEFAULT_FreeBSD_13= LTO OPTIONS_DEFAULT+= ${OPTIONS_DEFAULT_${OPSYS}_${OSREL:R}} CUPS_DESC= Enable support for cups CUPS_CONFIGURE_ENABLE= plugin-cups CUPS_LIB_DEPENDS= libcups.so:print/cups DBENGINE_DESC= Enable support for database engine DBENGINE_CONFIGURE_ENABLE= dbengine DBENGINE_LIB_DEPENDS= libJudy.so:devel/judy \ liblz4.so:archivers/liblz4 \ libuv.so:devel/libuv FREEIPMI_DESC= Enable support for freeipmi FREEIPMI_CONFIGURE_ENABLE= plugin-freeipmi FREEIPMI_LIB_DEPENDS= libfreeipmi.so:sysutils/freeipmi GOPLUGIN_DESC= Enable the go collector plugin GOPLUGIN_RUN_DEPENDS= ${LOCALBASE}/libexec/netdata/plugins.d/god.plugin:net-mgmt/netdata-go JSON_DESC= Enable support for json JSON_CONFIGURE_ENABLE= jsonc JSON_LIB_DEPENDS= libjson-c.so:devel/json-c LTO_DESC= Use Link-Time Optimization LTO_CONFIGURE_ENABLE= lto LTO_USES= compiler:c11 .include .if ${PORT_OPTIONS:MLTO} && ${OPSYS}_${OSREL:R} == FreeBSD_11 BROKEN= Link-Time Optimization breaks compilation on FreeBSD 11 .endif post-patch: @${REINPLACE_CMD} -e 's|%%NETDATA_CACHE%%|${NETDATA_CACHE}|g' \ ${PATCH_WRKSRC}/configure.ac @${REINPLACE_CMD} -e 's|%%NETDATA_LOG%%|${NETDATA_LOG}|g' \ ${PATCH_WRKSRC}/configure.ac @${REINPLACE_CMD} -e 's|%%NETDATA_PERST%%|${NETDATA_PERST}|g' \ ${PATCH_WRKSRC}/configure.ac @${REINPLACE_CMD} -e 's|%%ETCDIR%%|${ETCDIR}|g' \ ${PATCH_WRKSRC}/configure.ac @${REINPLACE_CMD} -e 's|%%PYTHON%%|${PYTHON_CMD}|g' \ ${PATCH_WRKSRC}/collectors/python.d.plugin/python.d.plugin.in post-install: ${MKDIR} ${STAGEDIR}${ETCDIR} ${INSTALL_DATA} ${WRKDIR}/netdata.conf.sample ${STAGEDIR}${ETCDIR}/netdata.conf.sample ${MKDIR} ${STAGEDIR}${NETDATA_CACHE} ${MKDIR} ${STAGEDIR}${NETDATA_LOG} ${MKDIR} ${STAGEDIR}${NETDATA_PERST} (for file in ${STAGEDIR}${LOCALBASE}/lib/${PORTNAME}/conf.d/*.conf \ ${STAGEDIR}${LOCALBASE}/lib/${PORTNAME}/conf.d/*/*.conf; do \ ${MV} $$file $$file".sample"; \ done) .include Index: head/net-mgmt/netdata/files/netdata.in =================================================================== --- head/net-mgmt/netdata/files/netdata.in (revision 530692) +++ head/net-mgmt/netdata/files/netdata.in (revision 530693) @@ -1,123 +1,126 @@ #!/bin/sh # # $FreeBSD$ # # PROVIDE: netdata # REQUIRE: LOGIN # KEYWORD: shutdown # # Add the following line to /etc/rc.conf to enable netdata: # netdata_enable (bool): Set to "NO" by default. # Set it to "YES" to enable netdata. # netdata_args (str): Custom additional arguments to be passed # to netdata (default empty). # netdata_conf (str): Custom configuration file for netdata # (default: %%ETCDIR%%/netdata.conf) # netdata_user (str): Custom user to run netdata as # (default: read from netdata_conf if # it is set there, or "netdata") # netdata_stop_maxwait (int): Maximum time to wait for termination on stop # before resorting to SIGKILL to stop netdata. # # Written 2017 - 2019 Mahdi Mokhtari (mmokhi@) # Written 2020 Matthias Andree (mandree@) with support by Dries Michiels . /etc/rc.subr name="netdata" rcvar=netdata_enable SED=/usr/bin/sed TR=/usr/bin/tr load_rc_config $name : ${netdata_enable="NO"} : ${netdata_conf="%%ETCDIR%%/${name}.conf"} : ${netdata_pid="%%NETDATA_PERST%%/${name}.pid"} : # netdata_user set below, it may also be pulled from the netdata_conf file : ${netdata_stop_maxwait=30} # read netdata_conf and print the "run as user =" RHS, or print nothing if unset # # only permits ASCII letters, digits, dash, underscore - does not permit # backtick, curly braces, angle brackets, backslash although passwd(5) would # permit these. get_user_from_conf() { $SED -n '/^\[global\]/,/^\[/{s/^[[:space:]]*run as user.*=[[:space:]]*\(.*\)[[:space:]]*$/\1/p;}' "${netdata_conf}" \ | $TR -c -d 'a-zA-Z0-9_-' } # check if the rc.conf* file set and netdata_conf agree on the name to run the bundle as check_user_consistency() { cfusr=$(get_user_from_conf) if [ -z "$cfusr" -o "$cfusr" = "${netdata_user}" ] ; then return 0 ; fi - echo >&2 "$0: ERROR: ${netdata_conf} sets 'run as user = $cfusr', but rc.conf* sets '${netdata_user}'. Both must be consistent." - return 1 + err 1 "${netdata_conf} sets 'run as user = $cfusr', but rc.conf* sets '${netdata_user}'. Both must be consistent." } # this is more or less a copy of /etc/rc.subr from 12.1-RELEASE # around Early April 2020, but with a timeout, killing children, # and SIGKILL added because sometimes netdata hangs. stop_cmd() { rc_pid=$(check_pidfile "${netdata_pid}" "${procname}") if [ -z "$rc_pid" ] ; then [ -n "$fc_fast" ] && return 0 _run_rc_notrunning return 1 fi _prefix= - slave_pids=$(pgrep -P $rc_pid) echo "Stopping ${name}." - _list="$rc_pid $slave_pids" + _list="$rc_pid $(pgrep -P $rc_pid)" kill -TERM $_list - wtim=0 + pwait -t 3 $_list 2>/dev/null + wtim=3 while :; do _nlist= for _j in $_list ; do if kill -0 $_j 2>/dev/null ; then - _nlist="$_nlist $_j" - [ -n "$_prefix" ] && sleep 1 + _nlist="$_nlist${_nlist:+" "}$_j" fi done if [ -z "$_nlist" ] ; then break fi _list=$_nlist echo -n ${_prefix:-"Waiting for PIDS: "}$_list _prefix=", " + sleep 1 pwait -t 2 $_list 2>/dev/null - wtim=$(($wtim + 3)) - if [ $wtim -gt ${netdata_stop_maxwait} ] ; then - echo -n "${_prefix}SIGKILL $_list" - kill -KILL $_list - break + if [ $? -eq 124 ] ; then + wtim=$(($wtim + 3)) + if [ $wtim -ge ${netdata_stop_maxwait} ] ; then + [ -n "$_prefix" ] && echo . + _prefix= + warn "${procname} has not terminated in ${netdata_stop_maxwait} s. Using SIGKILL $_list." + kill -KILL $_list + break + fi fi done [ -n "$_prefix" ] && echo . } stop_postcmd() { rm -f "${netdata_pid}" } # obtain default user, first from configuration, or default to "netdata" _netdata_user_default=$(get_user_from_conf) : ${_netdata_user_default:="netdata"} # and then, if rc.conf* don't set it, use the default : ${netdata_user="${_netdata_user_default}"} procname="%%PREFIX%%/sbin/${name}" command="/usr/sbin/daemon" command_args="-c -f \"${procname}\" -u \"${netdata_user}\" -P \"${netdata_pid}\" ${netdata_args}" required_files="${netdata_conf}" start_precmd=check_user_consistency stop_cmd=stop_cmd stop_postcmd=stop_postcmd # netdata always leaves its pid file behind. run_rc_command "$1"