commit:a42f6cbf7cf1bdce6d23002fac6102e8dfec21d0
author:Chip Black
committer:Chip Black
date:Fri Dec 30 18:37:13 2022 -0600
parents:88705935ba15db9d3438a4179e604792fc3fd2bc
Add log rotation and external log mount
diff --git a/build-mastodon.sh b/build-mastodon.sh
line changes: +5/-2
index c2b0de5..603af57
--- a/build-mastodon.sh
+++ b/build-mastodon.sh
@@ -45,10 +45,13 @@ rm env.production
 
 jexec -U mastodon $JAILNAME /bin/sh -c 'cd ~/live && RAILS_ENV=production bundle exec rails assets:precompile'
 
-bastille mount $JAILNAME $MEDIA_MOUNT usr/home/mastodon/live/public/system nullfs rw 0 0
+bastille mount $JAILNAME $DATA_PATH/media usr/home/mastodon/live/public/system nullfs rw 0 0
 jexec $JAILNAME /usr/sbin/chown mastodon:mastodon /home/mastodon/live/public/system
+bastille mount $JAILNAME $DATA_PATH/log var/log/mastodon nullfs rw 0 0
 
-bastille cp $JAILNAME rc.d /usr/local/etc/
+bastille cmd $JAILNAME mkdir /usr/local/etc/newsyslog.conf.d
+bastille cp $JAILNAME mastodon/newsyslog.conf /usr/local/etc/newsyslog.conf.d/mastodon.conf
+bastille cp $JAILNAME mastodon/rc.d /usr/local/etc/
 bastille sysrc $JAILNAME mastodon_enable=YES
 bastille service $JAILNAME mastodon-streaming start
 bastille service $JAILNAME mastodon-sidekiq start

diff --git a/dev.env b/dev.env
line changes: +7/-0
index 0000000..0697446
--- /dev/null
+++ b/dev.env
@@ -0,0 +1,7 @@
+POSTGRES_JAILNAME=postgres-test
+POSTGRES_ADDR=10.0.3.1
+REDIS_JAILNAME=redis-test
+REDIS_ADDR=10.0.3.2
+MASTODON_JAILNAME=mastodon-test
+MASTODON_ADDR=10.0.3.3
+HOSTNAME=awesome.garden

diff --git a/main-env.opts b/main-env.opts
line changes: +0/-17
index ad03737..0000000
--- a/main-env.opts
+++ /dev/null
@@ -1,17 +0,0 @@
-POSTGRES_JAILNAME=postgres
-POSTGRES_ADDR=10.0.1.1
-REDIS_JAILNAME=redis
-REDIS_ADDR=10.0.1.2
-MASTODON_JAILNAME=mastodon
-MASTODON_ADDR=10.0.1.3
-HOSTNAME=awesome.garden
-
-MEDIA_MOUNT=/mastodon-media
-
-# Secrets
-SECRET_KEY_BASE=ebbdf56ea127cc6bdb74cbe6c692d7d9fa646bdf4128e1a517ce77907abd08b90ead57b86f1b193106c43c1832a8983346dd096eb1d5b908dd57acb3463a1d46
-OTP_SECRET=903dad54615b2618c2f737149504b93a0e46e0bac7bdb46eb489ea25151397403164859463df697792f935cf827bcbaa53c7b95dff84e2d5bf26d795f765f33b
-VAPID_PRIVATE_KEY=l35ase3E2JU3YN-NTdoki32-X9JIYgfqmCDmXZwrQWA=
-VAPID_PUBLIC_KEY=BJTa2zMR_NNFYNFYnTwGRVo7Xfovvbo1RUR5ZCtnxMWAjtdrqjf17RlLjdfmD20JGOZ5UvV5keeJNdOMR87Z9H0=
-SMTP_LOGIN=sumomo
-SMTP_PASSWORD=aNKu62OUSX0rjaEz

diff --git a/mastodon/newsyslog.conf b/mastodon/newsyslog.conf
line changes: +3/-0
index 0000000..54f54b1
--- /dev/null
+++ b/mastodon/newsyslog.conf
@@ -0,0 +1,3 @@
+/var/log/mastodon/streaming.log root:wheel 440 90 * @T06 Xp /var/run/mastodon-streaming.pid
+/var/log/mastodon/sidekiq.log root:wheel 440 90 * @T06 Xp /var/run/mastodon-sidekiq.pid
+/var/log/mastodon/web.log root:wheel 440 90 * @T06 Xp /var/run/mastodon-web.pid

diff --git a/mastodon/rc.d/mastodon-sidekiq b/mastodon/rc.d/mastodon-sidekiq
line changes: +22/-0
index 0000000..0124166
--- /dev/null
+++ b/mastodon/rc.d/mastodon-sidekiq
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+# PROVIDE: mastodon_sidekiq
+# REQUIRE: DAEMON mastodon_web
+# KEYWORD: shutdown
+
+. /etc/rc.subr
+
+name="mastodon_sidekiq"
+rcvar="mastodon_enable"
+
+pidfile="/var/run/mastodon-sidekiq.pid"
+mastodon_sidekiq_chdir="/home/mastodon/live"
+mastodon_sidekiq_env="RAILS_ENV=production"
+command="/usr/sbin/daemon"
+command_args="-u mastodon -P ${pidfile} -H -o /var/log/mastodon/sidekiq.log /usr/local/bin/bundle exec sidekiq -c 25"
+
+# read configuration and set defaults
+load_rc_config "$name"
+: ${mastodon_enable="NO"}
+
+run_rc_command "$1"

diff --git a/mastodon/rc.d/mastodon-streaming b/mastodon/rc.d/mastodon-streaming
line changes: +22/-0
index 0000000..f7e74d0
--- /dev/null
+++ b/mastodon/rc.d/mastodon-streaming
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+# PROVIDE: mastodon_streaming
+# REQUIRE: DAEMON mastodon_web
+# KEYWORD: shutdown
+
+. /etc/rc.subr
+
+name="mastodon_streaming"
+rcvar="mastodon_enable"
+
+pidfile="/var/run/mastodon-streaming.pid"
+mastodon_streaming_chdir="/home/mastodon/live"
+mastodon_streaming_env="NODE_ENV=production PORT=4000 STREAMING_CLUSTER_NUM=1"
+command="/usr/sbin/daemon"
+command_args="-u mastodon -P ${pidfile} -H -o /var/log/mastodon/streaming.log /usr/local/bin/node ./streaming"
+
+# read configuration and set defaults
+load_rc_config "$name"
+: ${mastodon_enable="NO"}
+
+run_rc_command "$1"

diff --git a/mastodon/rc.d/mastodon-web b/mastodon/rc.d/mastodon-web
line changes: +22/-0
index 0000000..816dd35
--- /dev/null
+++ b/mastodon/rc.d/mastodon-web
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+# PROVIDE: mastodon_web
+# REQUIRE: DAEMON
+# KEYWORD: shutdown
+
+. /etc/rc.subr
+
+name="mastodon_web"
+rcvar="mastodon_enable"
+
+pidfile="/var/run/mastodon-web.pid"
+mastodon_web_chdir="/home/mastodon/live"
+mastodon_web_env="RAILS_ENV=production"
+command="/usr/sbin/daemon"
+command_args="-u mastodon -P ${pidfile} -H -o /var/log/mastodon/web.log /usr/local/bin/bundle exec puma -C config/puma.rb"
+
+# read configuration and set defaults
+load_rc_config "$name"
+: ${mastodon_enable="NO"}
+
+run_rc_command "$1"

diff --git a/prod.env b/prod.env
line changes: +17/-0
index 0000000..2c08419
--- /dev/null
+++ b/prod.env
@@ -0,0 +1,17 @@
+POSTGRES_JAILNAME=postgres
+POSTGRES_ADDR=10.0.1.1
+REDIS_JAILNAME=redis
+REDIS_ADDR=10.0.1.2
+MASTODON_JAILNAME=mastodon
+MASTODON_ADDR=10.0.1.3
+HOSTNAME=awesome.garden
+
+DATA_PATH=/mastodon
+
+# Secrets
+SECRET_KEY_BASE=ebbdf56ea127cc6bdb74cbe6c692d7d9fa646bdf4128e1a517ce77907abd08b90ead57b86f1b193106c43c1832a8983346dd096eb1d5b908dd57acb3463a1d46
+OTP_SECRET=903dad54615b2618c2f737149504b93a0e46e0bac7bdb46eb489ea25151397403164859463df697792f935cf827bcbaa53c7b95dff84e2d5bf26d795f765f33b
+VAPID_PRIVATE_KEY=l35ase3E2JU3YN-NTdoki32-X9JIYgfqmCDmXZwrQWA=
+VAPID_PUBLIC_KEY=BJTa2zMR_NNFYNFYnTwGRVo7Xfovvbo1RUR5ZCtnxMWAjtdrqjf17RlLjdfmD20JGOZ5UvV5keeJNdOMR87Z9H0=
+SMTP_LOGIN=sumomo
+SMTP_PASSWORD=aNKu62OUSX0rjaEz

diff --git a/rc.d/mastodon-sidekiq b/rc.d/mastodon-sidekiq
line changes: +0/-22
index 3de21fe..0000000
--- a/rc.d/mastodon-sidekiq
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/sh
-
-# PROVIDE: mastodon_sidekiq
-# REQUIRE: DAEMON mastodon_web
-# KEYWORD: shutdown
-
-. /etc/rc.subr
-
-name="mastodon_sidekiq"
-rcvar="mastodon_enable"
-
-pidfile="/var/run/mastodon-sidekiq.pid"
-mastodon_sidekiq_chdir="/home/mastodon/live"
-mastodon_sidekiq_env="RAILS_ENV=production"
-command="/usr/sbin/daemon"
-command_args="-u mastodon -P ${pidfile} -H -o /var/log/mastodon-sidekiq.log /usr/local/bin/bundle exec sidekiq -c 25"
-
-# read configuration and set defaults
-load_rc_config "$name"
-: ${mastodon_enable="NO"}
-
-run_rc_command "$1"

diff --git a/rc.d/mastodon-streaming b/rc.d/mastodon-streaming
line changes: +0/-22
index cf49e9d..0000000
--- a/rc.d/mastodon-streaming
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/sh
-
-# PROVIDE: mastodon_streaming
-# REQUIRE: DAEMON mastodon_web
-# KEYWORD: shutdown
-
-. /etc/rc.subr
-
-name="mastodon_streaming"
-rcvar="mastodon_enable"
-
-pidfile="/var/run/mastodon-streaming.pid"
-mastodon_streaming_chdir="/home/mastodon/live"
-mastodon_streaming_env="NODE_ENV=production PORT=4000 STREAMING_CLUSTER_NUM=1"
-command="/usr/sbin/daemon"
-command_args="-u mastodon -P ${pidfile} -H -o /var/log/mastodon-streaming.log /usr/local/bin/node ./streaming"
-
-# read configuration and set defaults
-load_rc_config "$name"
-: ${mastodon_enable="NO"}
-
-run_rc_command "$1"

diff --git a/rc.d/mastodon-web b/rc.d/mastodon-web
line changes: +0/-22
index 8f18591..0000000
--- a/rc.d/mastodon-web
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/sh
-
-# PROVIDE: mastodon_web
-# REQUIRE: DAEMON
-# KEYWORD: shutdown
-
-. /etc/rc.subr
-
-name="mastodon_web"
-rcvar="mastodon_enable"
-
-pidfile="/var/run/mastodon-web.pid"
-mastodon_web_chdir="/home/mastodon/live"
-mastodon_web_env="RAILS_ENV=production"
-command="/usr/sbin/daemon"
-command_args="-u mastodon -P ${pidfile} -H -o /var/log/mastodon-web.log /usr/local/bin/bundle exec puma -C config/puma.rb"
-
-# read configuration and set defaults
-load_rc_config "$name"
-: ${mastodon_enable="NO"}
-
-run_rc_command "$1"

diff --git a/test-env.opts b/test-env.opts
line changes: +0/-7
index 0697446..0000000
--- a/test-env.opts
+++ /dev/null
@@ -1,7 +0,0 @@
-POSTGRES_JAILNAME=postgres-test
-POSTGRES_ADDR=10.0.3.1
-REDIS_JAILNAME=redis-test
-REDIS_ADDR=10.0.3.2
-MASTODON_JAILNAME=mastodon-test
-MASTODON_ADDR=10.0.3.3
-HOSTNAME=awesome.garden