#!/bin/sh # $FreeBSD: head/sysutils/datadog-agent/files/datadog-trace-agent.in 554912 2020-11-11 20:25:33Z dch $ # # PROVIDE: datadog_trace_agent # REQUIRE: LOGIN # KEYWORD: shutdown # # Add the following lines to /etc/rc.conf.local or /etc/rc.conf # to enable this service: # # datadog_trace_agent_enable (bool): Set to NO by default. # Set it to YES to enable Datadog trace Agent. # datadog_trace_agent_user (user): Set user to run Datadog trace Agent. # Default is "%%USER%%". # datadog_trace_agent_conf (path): Path to Datadog trace Agent configuration file. # Default is %%ETCDIR%%/datadog.yaml . /etc/rc.subr name=datadog_trace_agent rcvar=datadog_trace_agent_enable load_rc_config $name : ${datadog_trace_agent_enable:="NO"} : ${datadog_trace_agent_user:="%%USER%%"} : ${datadog_trace_agent_conf:="%%ETCDIR%%/datadog.yaml"} command="%%DATADOG_PREFIX%%/trace-agent" command_args="-config ${datadog_trace_agent_conf}" required_files=%%ETCDIR%%/datadog.yaml pidfile="%%RUNDIR%%/datadog-agent-trace.pid" start_cmd="${name}_start start $@" stop_cmd="${name}_stop stop $@" status_cmd="${name}_status" datadog_trace_agent_status() { rc_pid=`check_pidfile ${pidfile} ${command}` if [ -n "${rc_pid}" ]; then echo "Datadog trace agent is running as pid ${rc_pid}." else echo "Datadog trace agent is not running." return 1 fi } datadog_trace_agent_start() { /usr/sbin/daemon -f -p ${pidfile} -u ${datadog_trace_agent_user} ${command} ${command_args} return $? } datadog_trace_agent_stop() { rc_pid=`check_pidfile ${pidfile} ${command}` if [ -n "${rc_pid}" ]; then kill ${rc_pid} else echo "Datadog trace agent is not running." fi } run_rc_command "$@"