From 1bebea4f50f73a39140be862b10f2dbf4a4da1f5 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Fri, 26 Jun 2026 23:07:16 +0200 Subject: update unicorn and rc.d docs --- doc/rc.d_cccms | 35 +++++++++++++++++++++++++++++++++++ doc/unicorn.rb | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 doc/rc.d_cccms create mode 100644 doc/unicorn.rb (limited to 'doc') diff --git a/doc/rc.d_cccms b/doc/rc.d_cccms new file mode 100644 index 0000000..62e8bde --- /dev/null +++ b/doc/rc.d_cccms @@ -0,0 +1,35 @@ +#!/bin/sh +# +# PROVIDE: cccms +# REQUIRE: LOGIN postgresql +# KEYWORD: shutdown + +. /etc/rc.subr + +name="cccms" +rcvar="cccms_enable" +desc="CCC CMS unicorn server" + +cccms_dir="${cccms_dir:-/usr/local/www/cccms}" +cccms_unicorn_config="${cccms_unicorn_config:-/usr/local/etc/unicorn.rb}" + +command="/usr/local/rvm/gems/ruby-3.2.11@rails7-upgrade/wrappers/unicorn" +command_args="-c ${cccms_unicorn_config} -E production -D" +cccms_chdir="${cccms_dir}" + +pidfile="${cccms_pidfile:-${cccms_dir}/tmp/pids/unicorn.pid}" +procname="ruby" + +required_dirs="${cccms_dir}" + +extra_commands="reload" +sig_reload="USR2" + +export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin +export RAILS_ENV=production +export HOME=/root + +load_rc_config "${name}" +: ${cccms_enable:="NO"} + +run_rc_command "$1" diff --git a/doc/unicorn.rb b/doc/unicorn.rb new file mode 100644 index 0000000..7f51822 --- /dev/null +++ b/doc/unicorn.rb @@ -0,0 +1,36 @@ +# This usually is deployed to /usr/local/etc/unicorn.rb +# and then executed from the rc.d/cccms script +# +# +# unicorn -c /usr/local/etc/unicorn.rb -E production -D + +stderr_path "/var/log/unicorn.stderr.log" + +rails_env = ENV['RAILS_ENV'] || 'production' + +worker_processes (rails_env == 'production' ? 32 : 4) + +preload_app true + +timeout 30 + +listen "0.0.0.0:9090", tcp_nopush: false + +pid "/usr/local/www/cccms/tmp/pids/unicorn.pid" + +before_fork do |server, worker| + old_pid = Rails.root.to_s + '/tmp/pids/unicorn.pid.oldbin' + if File.exist?(old_pid) && server.pid != old_pid + begin + Process.kill("QUIT", File.read(old_pid).to_i) + rescue Errno::ENOENT, Errno::ESRCH + # someone else did our job for us + end + end +end + +after_fork do |server, worker| + ActiveRecord::Base.establish_connection +end + +user 'www', 'www' -- cgit v1.3