tempestas

A REST API for processing sensor.community data
git clone https://git.bracken.jp/tempestas.git
Log | Files | Refs | README | LICENSE

tempestas (1352B)


      1 #!/bin/sh
      2 
      3 # PROVIDE: tempestas
      4 # REQUIRE: LOGIN cleanvar
      5 # KEYWORD: shutdown
      6 
      7 #
      8 # Add the following lines to /etc/rc.conf to enable tempestas:
      9 # tempestas_enable (bool):		Set to "NO" by default.
     10 #				Set it to "YES" to enable tempestas
     11 # tempestaslimits_enable (bool):	Set to "NO" by default.
     12 #				Set it to yes to run `limits $limits_args`
     13 #				just before tempestas starts.
     14 # tempestas_flags (str):		Set to "" by default.
     15 #				Extra flags passed to start command.
     16 # tempestaslimits_args (str):	Default to "-e -U tempestas"
     17 #				Arguments of pre-start limits run.
     18 
     19 . /etc/rc.subr
     20 
     21 name="tempestas"
     22 rcvar=tempestas_enable
     23 
     24 command="/usr/local/bin/tempestas"
     25 tempestas_user="tempestas"
     26 pidfile="/var/run/${name}.pid"
     27 
     28 start_cmd="tempestas_start"
     29 stop_cmd="tempestas_stop"
     30 status_cmd="tempestas_status"
     31 
     32 [ -z "$tempestas_enable" ]	&& tempestas_enable="NO"
     33 [ -z "$tempestas_flags" ]	&& tempestas_flags=""
     34 
     35 load_rc_config $name
     36 
     37 tempestas_start() {
     38 	/usr/sbin/daemon -P "${pidfile}" -r -f -S -T tempestas -u ${tempestas_user} "${command}" ${tempestas_flags}
     39 }
     40 
     41 tempestas_stop() {
     42 	if [ -e "${pidfile}" ]; then
     43 		kill -s TERM `cat ${pidfile}`
     44 	else
     45 		echo "${name} is not running"
     46 	fi
     47 }
     48 
     49 tempestas_status() {
     50 	if [ -e "${pidfile}" ]; then
     51 		echo "${name} is running as pid `cat ${pidfile}`"
     52 	else
     53 		echo "${name} is not running"
     54 	fi
     55 }
     56 
     57 run_rc_command "$1"