Add rc.d scripts for FreeBSD.

This commit is contained in:
Mastodon service
2022-11-15 19:06:54 +01:00
commit fc8de02fe2
3 changed files with 140 additions and 0 deletions

47
mastodon_sidekiq Executable file
View File

@@ -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"

46
mastodon_streaming Executable file
View File

@@ -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"

47
mastodon_web Executable file
View File

@@ -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"