diff options
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/rc.d_cccms | 35 | ||||
| -rw-r--r-- | doc/unicorn.rb | 36 |
2 files changed, 71 insertions, 0 deletions
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 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # | ||
| 3 | # PROVIDE: cccms | ||
| 4 | # REQUIRE: LOGIN postgresql | ||
| 5 | # KEYWORD: shutdown | ||
| 6 | |||
| 7 | . /etc/rc.subr | ||
| 8 | |||
| 9 | name="cccms" | ||
| 10 | rcvar="cccms_enable" | ||
| 11 | desc="CCC CMS unicorn server" | ||
| 12 | |||
| 13 | cccms_dir="${cccms_dir:-/usr/local/www/cccms}" | ||
| 14 | cccms_unicorn_config="${cccms_unicorn_config:-/usr/local/etc/unicorn.rb}" | ||
| 15 | |||
| 16 | command="/usr/local/rvm/gems/ruby-3.2.11@rails7-upgrade/wrappers/unicorn" | ||
| 17 | command_args="-c ${cccms_unicorn_config} -E production -D" | ||
| 18 | cccms_chdir="${cccms_dir}" | ||
| 19 | |||
| 20 | pidfile="${cccms_pidfile:-${cccms_dir}/tmp/pids/unicorn.pid}" | ||
| 21 | procname="ruby" | ||
| 22 | |||
| 23 | required_dirs="${cccms_dir}" | ||
| 24 | |||
| 25 | extra_commands="reload" | ||
| 26 | sig_reload="USR2" | ||
| 27 | |||
| 28 | export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin | ||
| 29 | export RAILS_ENV=production | ||
| 30 | export HOME=/root | ||
| 31 | |||
| 32 | load_rc_config "${name}" | ||
| 33 | : ${cccms_enable:="NO"} | ||
| 34 | |||
| 35 | 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 @@ | |||
| 1 | # This usually is deployed to /usr/local/etc/unicorn.rb | ||
| 2 | # and then executed from the rc.d/cccms script | ||
| 3 | # | ||
| 4 | # | ||
| 5 | # unicorn -c /usr/local/etc/unicorn.rb -E production -D | ||
| 6 | |||
| 7 | stderr_path "/var/log/unicorn.stderr.log" | ||
| 8 | |||
| 9 | rails_env = ENV['RAILS_ENV'] || 'production' | ||
| 10 | |||
| 11 | worker_processes (rails_env == 'production' ? 32 : 4) | ||
| 12 | |||
| 13 | preload_app true | ||
| 14 | |||
| 15 | timeout 30 | ||
| 16 | |||
| 17 | listen "0.0.0.0:9090", tcp_nopush: false | ||
| 18 | |||
| 19 | pid "/usr/local/www/cccms/tmp/pids/unicorn.pid" | ||
| 20 | |||
| 21 | before_fork do |server, worker| | ||
| 22 | old_pid = Rails.root.to_s + '/tmp/pids/unicorn.pid.oldbin' | ||
| 23 | if File.exist?(old_pid) && server.pid != old_pid | ||
| 24 | begin | ||
| 25 | Process.kill("QUIT", File.read(old_pid).to_i) | ||
| 26 | rescue Errno::ENOENT, Errno::ESRCH | ||
| 27 | # someone else did our job for us | ||
| 28 | end | ||
| 29 | end | ||
| 30 | end | ||
| 31 | |||
| 32 | after_fork do |server, worker| | ||
| 33 | ActiveRecord::Base.establish_connection | ||
| 34 | end | ||
| 35 | |||
| 36 | user 'www', 'www' | ||
