summaryrefslogtreecommitdiff
path: root/installation/netbsd/rc.d/pleroma
blob: 1114668eeb72f3fa6154ce37584574af57eb24d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh
# PROVIDE: pleroma
# REQUIRE: DAEMON pgsql

if [ -f /etc/rc.subr ]; then
	. /etc/rc.subr
fi

name="pleroma"
rcvar=${name}
command="/usr/pkg/bin/elixir"
command_args="--detached -S /usr/pkg/bin/mix phx.server"
start_precmd="ulimit -n unlimited"
pidfile="/dev/null"

pleroma_chdir="${pleroma_home}/pleroma"
pleroma_env="HOME=${pleroma_home} MIX_ENV=prod"

check_pidfile()
{
	pid=$(pgrep -U "${pleroma_user}" /bin/beam.smp$)
	echo -n "${pid}"
}

if [ -f /etc/rc.subr -a -d /etc/rc.d -a -f /etc/rc.d/DAEMON ]; then
	# newer NetBSD
	load_rc_config ${name}
	run_rc_command "$1"
else
	# ancient NetBSD, Solaris and illumos, Linux, etc...
	cmd=${1:-start}

	case ${cmd} in
		start)
			echo "Starting ${name}."
			${start_cmd}
			;;

		stop)
			echo "Stopping ${name}."
			check_pidfile
			! [ -n ${pid} ] && kill ${pid}
			;;

		restart)
			( $0 stop )
			sleep 5
			$0 start
			;;

		*)
			echo 1>&2 "Usage: $0 [start|stop|restart]"
			exit 1
			;;
	esac
	exit 0
fi