Merge branch 'testfix/webfinger-jrd' into 'develop'
[akkoma] / installation / netbsd / rc.d / pleroma
1 #!/bin/sh
2 # PROVIDE: pleroma
3 # REQUIRE: DAEMON pgsql
4
5 if [ -f /etc/rc.subr ]; then
6 . /etc/rc.subr
7 fi
8
9 name="pleroma"
10 rcvar=${name}
11 command="/usr/pkg/bin/elixir"
12 command_args="--detached -S /usr/pkg/bin/mix phx.server"
13 start_precmd="ulimit -n unlimited"
14 pidfile="/dev/null"
15
16 pleroma_chdir="${pleroma_home}/pleroma"
17 pleroma_env="HOME=${pleroma_home} MIX_ENV=prod"
18
19 check_pidfile()
20 {
21 pid=$(pgrep -U "${pleroma_user}" /bin/beam.smp$)
22 echo -n "${pid}"
23 }
24
25 if [ -f /etc/rc.subr -a -d /etc/rc.d -a -f /etc/rc.d/DAEMON ]; then
26 # newer NetBSD
27 load_rc_config ${name}
28 run_rc_command "$1"
29 else
30 # ancient NetBSD, Solaris and illumos, Linux, etc...
31 cmd=${1:-start}
32
33 case ${cmd} in
34 start)
35 echo "Starting ${name}."
36 ${start_cmd}
37 ;;
38
39 stop)
40 echo "Stopping ${name}."
41 check_pidfile
42 ! [ -n ${pid} ] && kill ${pid}
43 ;;
44
45 restart)
46 ( $0 stop )
47 sleep 5
48 $0 start
49 ;;
50
51 *)
52 echo 1>&2 "Usage: $0 [start|stop|restart]"
53 exit 1
54 ;;
55 esac
56 exit 0
57 fi