DEV: use unicorn in development
This commit also cleans up a bunch of pointless noise each time we boot app - narrative was loading i18n cause redefinition of consts - discourse.rb was loaded twice as was auth - bin/unicorn now does all the smart things and boots unicron in dev - bin/rails s will boot unicorn with no params - remove bin/puma which only causes confusion
This commit is contained in:
parent
2b57239389
commit
f3549291a3
32
bin/puma
32
bin/puma
|
@ -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')
|
|
@ -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'
|
||||
|
|
|
@ -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')
|
|
@ -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 this
|
||||
|
|
|
@ -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_config
|
||||
end
|
||||
|
|
|
@ -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 filesystem
|
||||
pid (ENV["UNICORN_PID_PATH"] || "#{discourse_path}/tmp/pids/unicorn.pid")
|
||||
|
||||
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.0
|
||||
preload_app true
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
require_dependency 'i18n'
|
||||
require_dependency 'user'
|
||||
|
||||
module Jobs
|
||||
|
|
Loading…
Reference in New Issue