A platform for community discussion. Free, open, simple.
DEV: use unicorn in development
Samf3549291a361
diff --git a/bin/puma b/bin/pumadeleted file mode 100755index 3249ddee001..00000000000--- a/bin/puma+++ /dev/null@@ -1,32 +0,0 @@-#!/usr/bin/env ruby-#-# This file was generated by Bundler.-#-# The application 'puma' is installed as part of a gem, and-# this file is here to facilitate running it.-#--if ARGV[0] == '--kill-existing'- ARGV.delete_at(0)-- pids = `ps aux | grep puma | grep discourse | grep -v grep | awk '{print $2;}'`.strip- .split("\n")- .map(&:to_i)- .reject { |pid| pid == Process.pid }-- if pids.length > 0- STDERR.puts "Terminating old version of puma at pid #{pids[0]}"- `kill -9 #{pids[0]}`- sleep 1- end--end--require 'pathname'-ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",- Pathname.new(__FILE__).realpath)--require 'rubygems'-require 'bundler/setup'--load Gem.bin_path('puma', 'puma')diff --git a/bin/rails b/bin/railsindex 07396602377..57d0505314d 100755--- a/bin/rails+++ b/bin/rails@@ -1,4 +1,9 @@#!/usr/bin/env ruby++if !ENV["RAILS_ENV"] && (ARGV == ["s"] || ARGV["server"])+ exec File.expand_path("unicorn", __dir__)+end+APP_PATH = File.expand_path('../config/application', __dir__)require_relative '../config/boot'require 'rails/commands'diff --git a/bin/unicorn b/bin/unicornnew file mode 100755index 00000000000..77c45fa4e96--- /dev/null+++ b/bin/unicorn@@ -0,0 +1,29 @@+#!/usr/bin/env ruby++require 'pathname'+ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",+ Pathname.new(__FILE__).realpath)++require 'rubygems'+require 'bundler/setup'++# in development do some fussing around, to automate config+if !ARGV.include?("-E") &&+ !ARGV.include?("--env") &&+ (ENV["RAILS_ENV"] == "development" || !ENV["RAILS_ENV"])++ ARGV.push("-N")+ if !ARGV.include?("-c") && !ARGV.include?("--config-file")+ ARGV.push("-c")+ ARGV.push(File.expand_path("../../config/unicorn.conf.rb",+ Pathname.new(__FILE__).realpath))+ end++ ENV["UNICORN_PORT"] = "9292"++ if !ENV["UNICORN_SIDEKIQS"]+ ENV["UNICORN_SIDEKIQS"] = "1"+ end+end++load Gem.bin_path('unicorn', 'unicorn')diff --git a/config/application.rb b/config/application.rbindex 2bb727bc01f..44599fa1651 100644--- a/config/application.rb+++ b/config/application.rb@@ -49,12 +49,15 @@ module Discourse# Application configuration should go into files in config/initializers# -- all .rb files in that directory are automatically loaded.- require 'discourse'- require 'es6_module_transpiler/rails'- require 'js_locale_helper'+ # this pattern is somewhat odd but the reloader gets very+ # confused here if we load the deps without `lib` it thinks+ # discourse.rb is under the discourse folder incorrectly+ require_dependency 'lib/discourse'+ require_dependency 'lib/es6_module_transpiler/rails'+ require_dependency 'lib/js_locale_helper'# tiny file needed by site settings- require 'highlight_js/highlight_js'+ require_dependency 'lib/highlight_js/highlight_js'# mocha hates us, active_support/testing/mochaing.rb line 2 is requiring the wrong# require, patched in source, on upgrade remove thisdiff --git a/config/initializers/100-sidekiq.rb b/config/initializers/100-sidekiq.rbindex 38f4fa8aeaa..9f781ff7279 100644--- a/config/initializers/100-sidekiq.rb+++ b/config/initializers/100-sidekiq.rb@@ -1,5 +1,15 @@require "sidekiq/pausable"+module Sidekiq+ class CLI+ private++ def print_banner+ # banner takes up too much space+ end+ end+end+Sidekiq.configure_client do |config|config.redis = Discourse.sidekiq_redis_configenddiff --git a/config/unicorn.conf.rb b/config/unicorn.conf.rbindex 9c0e51c3d1b..d1d9c44b033 100644--- a/config/unicorn.conf.rb+++ b/config/unicorn.conf.rb@@ -5,9 +5,6 @@ if ENV["LOGSTASH_UNICORN_URI"]logger DiscourseLogstashLogger.logger(uri: ENV['LOGSTASH_UNICORN_URI'], type: :unicorn)end-# enable out of band gc out of the box, it is low risk and improves perf a lot-ENV['UNICORN_ENABLE_OOBGC'] ||= "1"-discourse_path = File.expand_path(File.expand_path(File.dirname(__FILE__)) + "/../")# tune down if not enough ram@@ -21,14 +18,22 @@ listen (ENV["UNICORN_PORT"] || 3000).to_i# nuke workers after 30 seconds instead of 60 seconds (the default)timeout 30+if !File.exist?("#{discourse_path}/tmp/pids")+ Dir.mkdir("#{discourse_path}/tmp/pids")+end+# feel free to point this anywhere accessible on the filesystempid (ENV["UNICORN_PID_PATH"] || "#{discourse_path}/tmp/pids/unicorn.pid")-# By default, the Unicorn logger will write to stderr.-# Additionally, some applications/frameworks log to stderr or stdout,-# so prevent them from going to /dev/null when daemonized here:-stderr_path "#{discourse_path}/log/unicorn.stderr.log"-stdout_path "#{discourse_path}/log/unicorn.stdout.log"+if ENV["RAILS_ENV"] == "development" || !ENV["RAILS_ENV"]+ logger Logger.new($stdout)+else+ # By default, the Unicorn logger will write to stderr.+ # Additionally, some applications/frameworks log to stderr or stdout,+ # so prevent them from going to /dev/null when daemonized here:+ stderr_path "#{discourse_path}/log/unicorn.stderr.log"+ stdout_path "#{discourse_path}/log/unicorn.stdout.log"+end# important for Ruby 2.0preload_app truediff --git a/plugins/discourse-narrative-bot/autoload/jobs/narrative_init.rb b/plugins/discourse-narrative-bot/autoload/jobs/narrative_init.rbindex 68fb003f112..226ec14ae8f 100644--- a/plugins/discourse-narrative-bot/autoload/jobs/narrative_init.rb+++ b/plugins/discourse-narrative-bot/autoload/jobs/narrative_init.rb@@ -1,4 +1,3 @@-require_dependency 'i18n'require_dependency 'user'module Jobs