Skip to content

Instantly share code, notes, and snippets.

@ecnelises
Last active April 24, 2022 15:06
Show Gist options
  • Save ecnelises/2d033bb2b078260c11bc29a4da9c5453 to your computer and use it in GitHub Desktop.
Save ecnelises/2d033bb2b078260c11bc29a4da9c5453 to your computer and use it in GitHub Desktop.
FreeBSD rc scripts for typical mastodon instances
#!/bin/sh
# PROVIDE: mastodon_job
# REQUIRE: postgresql networking
. /etc/rc.subr
name="mastodon_job"
rcvar="mastodon_job_enable"
mastodon_job_user="mastodon" # Your user to run the instance
mastodon_job_chdir="/home/${mastodon_job_user}/mastodon"
mastodon_job_command="/home/${mastodon_job_user}/.rbenv/shims/bundle exec sidekiq -c 25"
pidfile="/home/${mastodon_job_user}/mastodon/tmp/pids/sidekiq.pid"
command="/usr/sbin/daemon"
command_args="-P ${pidfile} -r -S ${mastodon_job_command}"
export RAILS_ENV=production
export DB_POOL=25
export MALLOC_ARENA_MAX=2
export PATH=/usr/local/bin:$PATH
load_rc_config $name
: ${mastodon_job_enable:=no}
run_rc_command "$1"
#!/bin/sh
# PROVIDE: mastodon_stream
# REQUIRE: postgresql networking
. /etc/rc.subr
name="mastodon_stream"
rcvar="mastodon_stream_enable"
mastodon_stream_user="mastodon" # Your user to run the instance
mastodon_stream_chdir="/home/${mastodon_stream_user}/mastodon"
mastodon_stream_command="/usr/local/bin/node /home/${mastodon_stream_user}/mastodon/streaming"
pidfile="/home/${mastodon_stream_user}/mastodon/tmp/pids/streaming.pid"
command="/usr/sbin/daemon"
command_args="-P ${pidfile} -r -S ${mastodon_stream_command}"
export NODE_ENV=production
export PORT=4000
export STREAMING_CLUSTER_NUM=1
export PATH=/usr/local/bin:$PATH
load_rc_config $name
: ${mastodon_stream_enable:=no}
run_rc_command "$1"
#!/bin/sh
# PROVIDE: mastodon_web
# REQUIRE: postgresql networking
. /etc/rc.subr
name="mastodon_web"
rcvar="mastodon_web_enable"
mastodon_web_user="mastodon" # Your user to run the instance
mastodon_web_chdir="/home/${mastodon_web_user}/mastodon"
mastodon_web_command="/home/${mastodon_web_user}/.rbenv/shims/bundle exec puma -C /home/${mastodon_web_user}/mastodon/config/puma.rb"
pidfile="/home/${mastodon_web_user}/mastodon/tmp/pids/web.pid"
command="/usr/sbin/daemon"
command_args="-P ${pidfile} -r -S ${mastodon_web_command}"
export RAILS_ENV=production
export PORT=3000
export HOME=/home/${mastodon_web_user}/mastodon
export PATH=/usr/local/bin:$PATH
load_rc_config $name
: ${mastodon_web_enable:=no}
run_rc_command "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment