From fc8de02fe2095c28a77bd410c552fd0b758ab18e Mon Sep 17 00:00:00 2001 From: Mastodon service Date: Tue, 15 Nov 2022 19:06:54 +0100 Subject: [PATCH] Add rc.d scripts for FreeBSD. --- mastodon_sidekiq | 47 ++++++++++++++++++++++++++++++++++++++++++++++ mastodon_streaming | 46 +++++++++++++++++++++++++++++++++++++++++++++ mastodon_web | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 140 insertions(+) create mode 100755 mastodon_sidekiq create mode 100755 mastodon_streaming create mode 100755 mastodon_web diff --git a/mastodon_sidekiq b/mastodon_sidekiq new file mode 100755 index 0000000..7c3a8c8 --- /dev/null +++ b/mastodon_sidekiq @@ -0,0 +1,47 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: mastodon_sidekiq +# REQUIRE: NETWORKING DAEMON postgres +# KEYWORD: shutdown + +# +# Add the following lines to /etc/rc.conf to mastodon_sidekiq: +# +#mastodon_sidekiq_enable="YES" + +. /etc/rc.subr + +name="mastodon_sidekiq" +rcvar="${name}_enable" +command="/usr/local/bin/bundle exec sidekiq -c 25" +command_interpreter="/usr/local/bin/ruby30" +start_cmd="${name}_start" +stop_cmd="${name}_stop" + +pid_file="/var/run/${name}.pid" + +mastodon_sidekiq_start(){ + chdir /home/mastodon/live + /usr/sbin/daemon -S -l daemon -s debug -T ${name} \ + -u mastodon \ + /usr/bin/env -i \ + "RAILS_ENV=production" "DB_POOL=25" "HOME=/home/mastodon" \ + "MALLOC_ARENA_MAX=2" "USER=mastodon" "PATH=/usr/local/bin:${PATH}" $command +} + +mastodon_sidekiq_stop(){ + if [ -f "$pid_file" ]; then + echo -n "Stopping services: ${name}" + kill -s INT $(cat "$pid_file") + echo "." + else + echo "It appears ${name} is not running." + fi +} + + +load_rc_config ${name} +run_rc_command "$1" diff --git a/mastodon_streaming b/mastodon_streaming new file mode 100755 index 0000000..04cde4c --- /dev/null +++ b/mastodon_streaming @@ -0,0 +1,46 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: mastodon_streaming +# REQUIRE: NETWORKING DAEMON postgres +# KEYWORD: shutdown + +# +# Add the following lines to /etc/rc.conf to mastodon_streaming: +# +#mastodon_streaming_enable="YES" + +. /etc/rc.subr + +name="mastodon_streaming" +rcvar="${name}_enable" +command="/usr/local/bin/node ./streaming" +start_cmd="${name}_start" +stop_cmd="${name}_stop" + +pid_file="/var/run/${name}.pid" + +mastodon_streaming_start(){ + chdir /home/mastodon/live + /usr/sbin/daemon -S -l daemon -s debug -T ${name} \ + -u mastodon \ + /usr/bin/env -i \ + "NODE_ENV=production" "PORT=4000" "HOME=/home/mastodon" \ + "STREAMING_CLUSTER_NUM=1" "USER=mastodon" "PATH=/usr/local/bin:${PATH}" $command +} + +mastodon_streaming_stop(){ + if [ -f "$pid_file" ]; then + echo -n "Stopping services: ${name}" + kill -s INT $(cat "$pid_file") + echo "." + else + echo "It appears ${name} is not running." + fi +} + + +load_rc_config ${name} +run_rc_command "$1" diff --git a/mastodon_web b/mastodon_web new file mode 100755 index 0000000..a7895ff --- /dev/null +++ b/mastodon_web @@ -0,0 +1,47 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: mastodon_web +# REQUIRE: NETWORKING DAEMON postgres +# KEYWORD: shutdown + +# +# Add the following lines to /etc/rc.conf to mastodon_web: +# +#mastodon_web_enable="YES" + +. /etc/rc.subr + +name="mastodon_web" +rcvar="${name}_enable" +command="/usr/local/bin/bundle exec puma -C config/puma.rb" +command_interpreter="/usr/local/bin/ruby" +start_cmd="${name}_start" +stop_cmd="${name}_stop" + +pid_file="/var/run/${name}.pid" + +mastodon_web_start(){ + chdir /home/mastodon/live + /usr/sbin/daemon -S -l daemon -s debug -T ${name} \ + -u mastodon \ + /usr/bin/env -i \ + "RAILS_ENV=production" "PORT=3000" "HOME=/home/mastodon" \ + "USER=mastodon" "PATH=/usr/local/bin:${PATH}" $command +} + +mastodon_web_stop(){ + if [ -f "$pid_file" ]; then + echo -n "Stopping services: ${name}" + kill -s INT $(cat "$pid_file") + echo "." + else + echo "It appears ${name} is not running." + fi +} + + +load_rc_config ${name} +run_rc_command "$1"