From b10d49dfbf3040449d8c4bd5ea726b9c2c4ebd45 Mon Sep 17 00:00:00 2001 From: seph Date: Thu, 15 Dec 2016 10:59:59 -0500 Subject: [PATCH 1/2] Add in support for /etc/default/datadog-agent and set nicelevel from it For debian systems, start-stop-daemon has a `--nicelevel` argument. For centos, daemon does not, but seems to honor the NICELEVEL environmental variable --- packaging/centos/datadog-agent.init | 5 +++++ packaging/debian/datadog-agent.init | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packaging/centos/datadog-agent.init b/packaging/centos/datadog-agent.init index 1352060bb7..dff1945e2a 100644 --- a/packaging/centos/datadog-agent.init +++ b/packaging/centos/datadog-agent.init @@ -42,6 +42,7 @@ DD_OPT_PROC_REGEX="dogstatsd|jmxfetch|go-metro" # Source function library. . /etc/rc.d/init.d/functions +[ -r /etc/default/datadog-agent ] && . /etc/default/datadog-agent check_status() { # run checks to determine if the service is running or use generic status @@ -136,6 +137,10 @@ start() { echo -n $'\n'"Resuming starting process."$'\n' fi + # NICELEVEL, if set, comes from /etc/default/datadog-agent. + # daemon will honor it, so we should export it. + export NICELEVEL + # no need to test for status before daemon, # the daemon function does the right thing echo -n "Starting Datadog Agent (using supervisord):" diff --git a/packaging/debian/datadog-agent.init b/packaging/debian/datadog-agent.init index 3b8544f853..8959dab109 100755 --- a/packaging/debian/datadog-agent.init +++ b/packaging/debian/datadog-agent.init @@ -30,6 +30,8 @@ COLLECTOR_PIDFILE="/opt/datadog-agent/run/dd-agent.pid" SYSTEM_PATH=/opt/datadog-agent/embedded/bin:/opt/datadog-agent/bin:$PATH DD_OPT_PROC_REGEX="dogstatsd|jmxfetch|go-metro" +[ -r /etc/default/datadog-agent ] && . /etc/default/datadog-agent + if [ ! -x $AGENTPATH ]; then echo "$AGENTPATH not found. Exiting." exit 0 @@ -133,7 +135,7 @@ case "$1" in log_daemon_msg "Starting $DESC (using supervisord)" "$NAME" - PATH=$SYSTEM_PATH start-stop-daemon --start --quiet --oknodo --exec $SUPERVISORD_PATH -- -c $SUPERVISOR_FILE --pidfile $SUPERVISOR_PIDFILE + PATH=$SYSTEM_PATH start-stop-daemon --start ${NICELEVEL:+"--nicelevel $NICELEVEL"} --quiet --oknodo --exec $SUPERVISORD_PATH -- -c $SUPERVISOR_FILE --pidfile $SUPERVISOR_PIDFILE if [ $? -ne 0 ]; then log_end_msg 1 fi From 11ecf4f5bea29bb5d9646629fecec79e6f2013fb Mon Sep 17 00:00:00 2001 From: seph Date: Wed, 7 Jun 2017 20:29:01 -0400 Subject: [PATCH 2/2] Update for centos convention --- packaging/centos/datadog-agent.init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/centos/datadog-agent.init b/packaging/centos/datadog-agent.init index dff1945e2a..b31019668c 100644 --- a/packaging/centos/datadog-agent.init +++ b/packaging/centos/datadog-agent.init @@ -42,7 +42,7 @@ DD_OPT_PROC_REGEX="dogstatsd|jmxfetch|go-metro" # Source function library. . /etc/rc.d/init.d/functions -[ -r /etc/default/datadog-agent ] && . /etc/default/datadog-agent +[ -r /etc/sysconfig/datadog-agent ] && . /etc/sysconfig/datadog-agent check_status() { # run checks to determine if the service is running or use generic status