diff --git a/.env.sample b/.env.sample index 9a9397b0e..1d6260fd8 100644 --- a/.env.sample +++ b/.env.sample @@ -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 # diff --git a/Procfile b/Procfile index 441f02216..00645ec15 100644 --- a/Procfile +++ b/Procfile @@ -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 diff --git a/config/unicorn/development.rb b/config/unicorn/development.rb index a1f7a7517..6a0115978 100644 --- a/config/unicorn/development.rb +++ b/config/unicorn/development.rb @@ -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" diff --git a/config/unicorn/unicorn.rb b/config/unicorn/unicorn.rb deleted file mode 100644 index 755b80484..000000000 --- a/config/unicorn/unicorn.rb +++ /dev/null @@ -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