1 OpenRC
Jakub Jirutka edited this page 2014-09-02 17:39:35 -07:00

/etc/init.d/haste-server:

#!/sbin/runscript

name="Haste server"
description="Haste is an open-source pastebin software written in node.js"

: ${haste_user:=haste}
: ${haste_group:=haste}
: ${haste_home:=/opt/haste-server}

: ${haste_log:=/var/log/haste/haste-server.log}
: ${haste_pidfile:=/run/haste/haste-server.pid}

node_command="/usr/bin/node"
node_command_args="$haste_home/server.js"

depend() {
	need redis
	use net
}

start() {
	ebegin "Starting Haste server"

	checkpath -d -o "$haste_user:$haste_group" -m750 "$(dirname "$haste_pidfile")"

	start-stop-daemon --start \
		--background --quiet \
		--chdir "$haste_home" \
		--user="$haste_user:$haste_group" \
		--make-pidfile --pidfile=$haste_pidfile \
		--stdout "$haste_log" --stderr "$haste_log" \
		--exec $node_command -- $node_command_args
	eend $?
}

stop() {
	ebegin "Stopping Haste server"
	start-stop-daemon --stop \
		--pidfile=$haste_pidfile \
		--exec $node_command
	eend $?
}

See also Installation#gentoo.