Merge branch 'develop' into stable
[akkoma] / installation / init.d / akkoma
1 #!/sbin/openrc-run
2 supervisor=supervise-daemon
3 command_user=akkoma:akkoma
4 command_background=1
5 # Ask process to terminate within 30 seconds, otherwise kill it
6 retry="SIGTERM/30/SIGKILL/5"
7 pidfile="/var/run/akkoma.pid"
8 directory=/opt/akkoma
9 healthcheck_delay=60
10 healthcheck_timer=30
11
12 : ${akkoma_port:-4000}
13
14 # Needs OpenRC >= 0.42
15 #respawn_max=0
16 #respawn_delay=5
17
18 # put akkoma_console=YES in /etc/conf.d/akkoma if you want to be able to
19 # connect to akkoma via an elixir console
20 if yesno "${akkoma_console}"; then
21 command=elixir
22 command_args="--name akkoma@127.0.0.1 --erl '-kernel inet_dist_listen_min 9001 inet_dist_listen_max 9001 inet_dist_use_interface {127,0,0,1}' -S mix phx.server"
23
24 start_post() {
25 einfo "You can get a console by using this command as akkoma's user:"
26 einfo "iex --name console@127.0.0.1 --remsh akkoma@127.0.0.1"
27 }
28 else
29 command=/usr/bin/mix
30 command_args="phx.server"
31 fi
32
33 export MIX_ENV=prod
34 export ERL_EPMD_ADDRESS=127.0.0.1
35
36 depend() {
37 need nginx postgresql
38 }
39
40 healthcheck() {
41 # put akkoma_health=YES in /etc/conf.d/akkoma if you want healthchecking
42 # and make sure you have curl installed
43 yesno "$akkoma_health" || return 0
44
45 curl -q "localhost:${akkoma_port}/api/akkoma/healthcheck"
46 }