alfazema.club-etc

ref: master

init.d/hometown-sidekiq


#!/sbin/openrc-run

name="hometown-sidekiq"
description="hometown sidekiq service"
HOMETOWN_USER=${HOMETOWN_USER:-deployer}
LOGS=/var/log/hometown-sidekiq.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 RAILS_ENV=production
	export DB_POOL=25
	export MALLOC_ARENA_MAX=2

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

	eend $?
}

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