diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-02 15:14:06 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-02 15:14:06 +0200 |
| commit | 4ffa03a809f19b3676e08e452475c0bc586a5ea9 (patch) | |
| tree | 4efeb568425c6fb5e6ff135544bc726b400ea055 /doc/rc.d_cccms | |
| parent | 175b408948e601d3db568768a309eed8f2edb307 (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.
Diffstat (limited to 'doc/rc.d_cccms')
| -rw-r--r-- | doc/rc.d_cccms | 31 |
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" | |||
| 11 | desc="CCC CMS unicorn server" | 11 | desc="CCC CMS unicorn server" |
| 12 | 12 | ||
| 13 | cccms_dir="${cccms_dir:-/usr/local/www/cccms}" | 13 | cccms_dir="${cccms_dir:-/usr/local/www/cccms}" |
| 14 | rvm_ruby_version=$(cat ${cccms_dir}/.ruby-version 2>/dev/null || echo "ruby-3.2.11") | ||
| 15 | rvm_gemset=$(cat ${cccms_dir}/.ruby-gemset 2>/dev/null || echo "rails8-upgrade") | ||
| 16 | rvm_gemset_path="/usr/local/rvm/gems/${rvm_ruby_version}@${rvm_gemset}" | ||
| 17 | |||
| 18 | command="${rvm_gemset_path}/wrappers/unicorn" | ||
| 19 | |||
| 14 | cccms_unicorn_config="${cccms_unicorn_config:-/usr/local/etc/unicorn.rb}" | 20 | cccms_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" | ||
| 17 | command="/usr/local/rvm/gems/ruby-3.2.11@rails8-upgrade/wrappers/unicorn" | ||
| 18 | command_args="-c ${cccms_unicorn_config} -E production -D" | 22 | command_args="-c ${cccms_unicorn_config} -E production -D" |
| 19 | cccms_chdir="${cccms_dir}" | 23 | cccms_chdir="${cccms_dir}" |
| 20 | 24 | ||
| @@ -23,9 +27,21 @@ procname="ruby" | |||
| 23 | 27 | ||
| 24 | required_dirs="${cccms_dir}" | 28 | required_dirs="${cccms_dir}" |
| 25 | 29 | ||
| 26 | extra_commands="reload" | 30 | extra_commands="reload regenerate_occurrences" |
| 27 | sig_reload="USR2" | 31 | sig_reload="USR2" |
| 28 | 32 | ||
| 33 | regenerate_occurrences_cmd="cccms_regenerate_occurrences" | ||
| 34 | cccms_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 | |||
| 29 | start_precmd="cccms_prestart" | 45 | start_precmd="cccms_prestart" |
| 30 | cccms_prestart() | 46 | cccms_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 | ||
| 53 | start_postcmd="cccms_poststart" | ||
| 54 | cccms_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 | |||
| 37 | export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin | 62 | export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin |
| 38 | export RAILS_ENV=production | 63 | export RAILS_ENV=production |
| 39 | export HOME=/root | 64 | export HOME=/root |
