From e547ac7062490730ed272376b7251a2da28cd6c8 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Tue, 9 Jun 2020 16:49:46 +0200 Subject: [PATCH] adding scripts/rc.template --- scripts/rc.template | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 scripts/rc.template diff --git a/scripts/rc.template b/scripts/rc.template new file mode 100644 index 0000000..dc27711 --- /dev/null +++ b/scripts/rc.template @@ -0,0 +1,47 @@ +#!/bin/sh + +# +# Add the following lines to /etc/rc.conf to configure eosio_api_healthcheck: +# +# eosio_api_healthcheck_args : arguments to the command. +# +# eosio_api_healthcheck_logfile : file to log to (default /var/log/${name}.log) +# + +# PROVIDE: {{ RC_NAME }} +# REQUIRE: netif FILESYSTEMS + +. /etc/rc.subr + +name="{{ RC_NAME }}" +desc="{{ DESCRIPTION }}" +command="{{ PROGRAM }}" +command_args="${eosio_api_healthcheck_args}" +logfile="${eosio_api_healthcheck_logfile:-/var/log/${name}.log}" +pidfile="/var/run/${name}.pid" + +start_cmd="${name}_start" +stop_cmd="${name}_stop" + +eosio_api_healthcheck_start() +{ + echo "Starting ${name}" + ${command} ${command_args} >${logfile} 2>&1 & + echo $! > ${pidfile} +} + +eosio_api_healthcheck_stop() +{ + rc_pid=$(check_pidfile ${pidfile} ${command}) + if $rc_pid; then + rc_pid=$(cat ${pidfile}) + kill -$sig_stop $rc_pid + wait_for_pids $rc_pid + else + _run_rc_notrunning + return 1 + fi +} + +load_rc_config $name +run_rc_command "$1"