* VRFS-188; settling on not embedding websocket-gateway inside of rails when in production due to passenger
This commit is contained in:
parent
1f516eef0b
commit
dbdc88a5d2
1
build
1
build
|
|
@ -63,6 +63,7 @@ if [ -n "$PACKAGE" ]; then
|
|||
echo "BUILD NUMBER is not defined"
|
||||
exit 1
|
||||
fi
|
||||
set -e
|
||||
# cache all gems local, and tell bundle to use local gems only
|
||||
bundle install --path vendor/bundle --local
|
||||
# prepare production acssets
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ SampleApp::Application.configure do
|
|||
# Generate digests for assets URLs
|
||||
config.assets.digest = true
|
||||
|
||||
config.assets.initialize_on_precompile = false
|
||||
|
||||
# Defaults to Rails.root.join("public/assets")
|
||||
# config.assets.manifest = YOUR_PATH
|
||||
|
||||
|
|
@ -31,7 +33,7 @@ SampleApp::Application.configure do
|
|||
config.force_ssl = false
|
||||
|
||||
# See everything in the log (default is :info)
|
||||
# config.log_level = :debug
|
||||
config.log_level = :debug
|
||||
|
||||
# Prepend all log lines with the following tags
|
||||
# config.log_tags = [ :subdomain, :uuid ]
|
||||
|
|
@ -70,4 +72,7 @@ SampleApp::Application.configure do
|
|||
|
||||
# Show the logging configuration on STDOUT
|
||||
config.show_log_configuration = true
|
||||
|
||||
# run websocket-gateway embedded
|
||||
config.websocket_gateway_enable = false
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,13 +10,7 @@ require 'jam_ruby'
|
|||
|
||||
module JamWebEventMachine
|
||||
|
||||
def self.start
|
||||
|
||||
Thread.abort_on_exception = true
|
||||
|
||||
# create a new thread separate from the Rails main thread that EventMachine can run on
|
||||
Thread.new do
|
||||
|
||||
def self.run_em
|
||||
EM.run do
|
||||
AMQP.start(:host => Rails.application.config.rabbitmq_host, :port => Rails.application.config.rabbitmq_port) do |connection|
|
||||
AMQP::Channel.new do |channel, open_ok|
|
||||
|
|
@ -33,9 +27,40 @@ module JamWebEventMachine
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.die_gracefully_on_signal
|
||||
Signal.trap("INT") { EM.stop }
|
||||
Signal.trap("TERM") { EM.stop }
|
||||
end
|
||||
|
||||
def self.start
|
||||
if defined?(PhusionPassenger)
|
||||
Rails.logger.debug("PhusionPassenger detected")
|
||||
|
||||
PhusionPassenger.on_event(:starting_worker_process) do |forked|
|
||||
# for passenger, we need to avoid orphaned threads
|
||||
if forked && EM.reactor_running?
|
||||
Rails.logger.debug("stopping EventMachine")
|
||||
EM.stop
|
||||
end
|
||||
Rails.logger.debug("starting EventMachine")
|
||||
Thread.new {
|
||||
run_em
|
||||
}
|
||||
die_gracefully_on_signal
|
||||
end
|
||||
else
|
||||
Rails.logger.debug("PhusionPassenger not detected")
|
||||
Thread.abort_on_exception = true
|
||||
|
||||
# create a new thread separate from the Rails main thread that EventMachine can run on
|
||||
Thread.new do
|
||||
run_em
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
JamWebEventMachine.start
|
||||
JamWebEventMachine.start
|
||||
|
|
|
|||
Loading…
Reference in New Issue