alfazema.club-etc

ref: master

init.d/hometown-streaming


#!/sbin/openrc-run

name="hometown-streaming"
description="hometown streaming service"
HOMETOWN_USER=${HOMETOWN_USER:-deployer}
LOGS=/var/log/hometown-streaming.log

depend() {
	need net
	use redis
}

start_pre() {
	checkpath -f "$LOGS" -m 644 -o "$HOMETOWN_USER:$HOMETOWN_USER"
}

start() {
	ebegin "Starting $name"
	cd /srv/hometown
	export NODE_ENV=production
	export PORT=4000
	export STREAMING_CLUSTER_NUM=1

	start-stop-daemon \
		-u ${HOMETOWN_USER} \
		-1 "$LOGS" \
		-2 "$LOGS" \
		--background \
		--make-pidfile \
		--pidfile /run/$name.pid \
		--exec /usr/bin/node -- \
			./streaming

	eend $?
}

stop() {
	ebegin "Stopping $name"
	start-stop-daemon --stop --exec /usr/bin/node --pidfile /run/$name.pid
	eend $?
}