[Docker] Update unicorn config for development

This commit is contained in:
Earlopain 2023-03-10 17:27:00 +01:00
parent 94efeddf04
commit 86a6e94390
No known key found for this signature in database
GPG Key ID: 6CFB948E15246897
4 changed files with 3 additions and 67 deletions

View File

@ -8,24 +8,6 @@
# In other words: put your shared config in .env.local, and your put
# environment-specific config in .env.development / .env.production / .env.test.
#
# Unicorn
#
# These settings only take effect when running with `bundle exec unicorn -c config/unicorn/unicorn.rb`.
# export UNICORN_ROOT="$(pwd)"
# export UNICORN_LISTEN=127.0.0.1:9000
# export UNICORN_PROCESSES=1
# export UNICORN_TIMEOUT=90
# export UNICORN_LOG="log/unicorn-${UNICORN_LISTEN}.log"
# export UNICORN_PIDFILE="$UNICORN_ROOT/tmp/pids/unicorn-${UNICORN_LISTEN}.pid"
# These only take effect if you're running unicorn as root in order to bind to
# port 80 and need to drop privileges. Reverse proxying behind nginx is a better idea.
# export UNICORN_USER=danbooru
# export UNICORN_GROUP=danbooru
#
# Rails
#

View File

@ -1,3 +1,4 @@
server: bin/rails server -p 9000 -b 0.0.0.0
# server: bundle exec unicorn -c config/unicorn/development.rb
jobs: bundle exec sidekiq -c 1 -q low_prio -q tags -q default -q high_prio -q video
cron: run-parts /etc/periodic/daily && crond -f

View File

@ -1,22 +1,16 @@
# Set your full path to application.
app_path = "/var/www/danbooru2/current"
app_path = "/app"
# Set unicorn options
worker_processes 2
preload_app false
timeout 180
listen "127.0.0.1:9000"
# Spawn unicorn master worker for user apps (group: apps)
user 'danbooru', 'danbooru'
listen "0.0.0.0:9000"
# Fill path to your app
working_directory app_path
# Should be 'production' by default, otherwise use other env
rails_env = ENV['RAILS_ENV'] || 'production'
# Log everything to one file
stderr_path "log/unicorn.log"
stdout_path "log/unicorn.log"

View File

@ -1,41 +0,0 @@
require "dotenv"
rails_env = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
Dotenv.load(".env.local", ".env.#{rails_env}", ".env")
addr = ENV["UNICORN_LISTEN"] || "127.0.0.1:9000"
app_path = ENV["UNICORN_ROOT"] || Dir.pwd
instance = "unicorn-#{addr}"
listen addr
worker_processes ENV["UNICORN_PROCESSES"].to_i || 1
timeout ENV["UNICORN_TIMEOUT"].to_i || 90
user = ENV["UNICORN_USER"] || "danbooru"
group = ENV["UNICORN_GROUP"] || "danbooru"
stderr_path ENV["UNICORN_LOG"] || "log/#{instance}.log"
stdout_path ENV["UNICORN_LOG"] || "log/#{instance}.log"
working_directory app_path
pid ENV["UNICORN_PIDFILE"] || "#{app_path}/tmp/pids/#{instance}.pid"
if rails_env == "production"
preload_app true
before_fork do |server, worker|
ActiveRecord::Base.connection.disconnect! if defined?(ActiveRecord::Base)
# Throttle the master from forking too quickly by sleeping. Due
# to the implementation of standard Unix signal handlers, this
# helps (but does not completely) prevent identical, repeated signals
# from being lost when the receiving process is busy.
sleep 1
end
after_fork do |server, worker|
ActiveRecord::Base.establish_connection if defined?(ActiveRecord::Base)
end
else
preload_app false
end