48 lines
1.2 KiB
Plaintext
48 lines
1.2 KiB
Plaintext
#!/sbin/openrc-run
|
|
|
|
. /etc/conf.d/mastodon
|
|
|
|
name="Mastodon streaming API service"
|
|
|
|
depend() {
|
|
use net
|
|
need mastodon
|
|
}
|
|
PORT="${SVCNAME#*.}"
|
|
|
|
|
|
checkconfig() {
|
|
if [ "$PORT" = "$SVCNAME" ]; then
|
|
eerror "You cannot call this init script directly. Yo
|
|
must create a symbolic link to it with the port number:"
|
|
eerror " ln -s /etc/init.d/mastodon-streaming /etc
|
|
eerror "And then call it instead:"
|
|
eerror " /etc/init.d/mastodon-streaming.4000 start
|
|
return 1
|
|
fi
|
|
return 0
|
|
}
|
|
|
|
start() {
|
|
checkconfig || return 1
|
|
ebegin "Starting Mastodon streaming API"
|
|
|
|
start-stop-daemon --start \
|
|
--background --quiet \
|
|
--chdir "${INSTALLROOT}" \
|
|
--user="${USER}" \
|
|
--make-pidfile --pidfile=${INSTALLROOT}/streaming.pid \
|
|
--exec /usr/bin/env -- NODE_ENV=production PORT="$PORT" \
|
|
/usr/bin/node ./streaming
|
|
eend $? "Failed to start mastodon streaming service"
|
|
}
|
|
|
|
stop() {
|
|
checkconfig || return 1
|
|
ebegin "Stopping Mastodon streaming API"
|
|
start-stop-daemon --stop \
|
|
--pidfile=${INSTALLROOT}/streaming.pid \
|
|
eend $?
|
|
}
|
|
|