summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-07-02 15:14:06 +0200
committererdgeist <erdgeist@erdgeist.org>2026-07-02 15:14:06 +0200
commit4ffa03a809f19b3676e08e452475c0bc586a5ea9 (patch)
tree4efeb568425c6fb5e6ff135544bc726b400ea055
parent175b408948e601d3db568768a309eed8f2edb307 (diff)
rc.d: gemset auto-detection, occurrence regeneration commanderdgeist-revive-events
- Derive rvm gemset path from .ruby-version and .ruby-gemset in the app directory, with fallback to current hardcoded values — no more manual rc.d edits on gemset changes - New extra command: service cccms regenerate_occurrences - Poststart staleness check: regenerates occurrences when marker file /var/db/cccms_occurrences_regenerated is missing or older than one year; runs only after successful server start, synchronously for error visibility Deployment note: updated script must be manually copied to /usr/local/etc/rc.d/cccms on live.
-rw-r--r--doc/rc.d_cccms31
1 files changed, 28 insertions, 3 deletions
diff --git a/doc/rc.d_cccms b/doc/rc.d_cccms
index 678ae75..909b372 100644
--- a/doc/rc.d_cccms
+++ b/doc/rc.d_cccms
@@ -11,10 +11,14 @@ rcvar="cccms_enable"
11desc="CCC CMS unicorn server" 11desc="CCC CMS unicorn server"
12 12
13cccms_dir="${cccms_dir:-/usr/local/www/cccms}" 13cccms_dir="${cccms_dir:-/usr/local/www/cccms}"
14rvm_ruby_version=$(cat ${cccms_dir}/.ruby-version 2>/dev/null || echo "ruby-3.2.11")
15rvm_gemset=$(cat ${cccms_dir}/.ruby-gemset 2>/dev/null || echo "rails8-upgrade")
16rvm_gemset_path="/usr/local/rvm/gems/${rvm_ruby_version}@${rvm_gemset}"
17
18command="${rvm_gemset_path}/wrappers/unicorn"
19
14cccms_unicorn_config="${cccms_unicorn_config:-/usr/local/etc/unicorn.rb}" 20cccms_unicorn_config="${cccms_unicorn_config:-/usr/local/etc/unicorn.rb}"
15 21
16# command="/usr/local/rvm/gems/ruby-3.2.11@rails7-upgrade/wrappers/unicorn"
17command="/usr/local/rvm/gems/ruby-3.2.11@rails8-upgrade/wrappers/unicorn"
18command_args="-c ${cccms_unicorn_config} -E production -D" 22command_args="-c ${cccms_unicorn_config} -E production -D"
19cccms_chdir="${cccms_dir}" 23cccms_chdir="${cccms_dir}"
20 24
@@ -23,9 +27,21 @@ procname="ruby"
23 27
24required_dirs="${cccms_dir}" 28required_dirs="${cccms_dir}"
25 29
26extra_commands="reload" 30extra_commands="reload regenerate_occurrences"
27sig_reload="USR2" 31sig_reload="USR2"
28 32
33regenerate_occurrences_cmd="cccms_regenerate_occurrences"
34cccms_regenerate_occurrences()
35{
36 cd ${cccms_dir} && \
37 ${rvm_gemset_path}/wrappers/bundle \
38 exec rails runner \
39 'Event.find_each { |e| Occurrence.generate(e) }' \
40 >> /var/log/unicorn.stderr.log 2>&1 && \
41 touch /var/db/cccms_occurrences_regenerated
42 echo "Occurrences regenerated."
43}
44
29start_precmd="cccms_prestart" 45start_precmd="cccms_prestart"
30cccms_prestart() 46cccms_prestart()
31{ 47{
@@ -34,6 +50,15 @@ cccms_prestart()
34 chown www:www /var/log/unicorn.stderr.log 50 chown www:www /var/log/unicorn.stderr.log
35} 51}
36 52
53start_postcmd="cccms_poststart"
54cccms_poststart()
55{
56 if [ -z "$(find /var/db/cccms_occurrences_regenerated -mtime -365 2>/dev/null)" ]; then
57 echo "Occurrences stale or missing, regenerating..."
58 cccms_regenerate_occurrences
59 fi
60}
61
37export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin 62export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
38export RAILS_ENV=production 63export RAILS_ENV=production
39export HOME=/root 64export HOME=/root