Merge branch 'work-in-process'. yo dawg, RUN YO' PROCESS IN YO' PROCESS.
This commit is contained in:
commit
2ab39013fd
5 changed files with 38 additions and 5 deletions
|
|
@ -96,6 +96,9 @@ default:
|
|||
# It is false by default in development and test.
|
||||
enable_splunk_logging: true
|
||||
|
||||
# Process jobs in process?
|
||||
single_process_mode: true
|
||||
|
||||
development:
|
||||
enable_splunk_logging: false
|
||||
|
||||
|
|
@ -105,3 +108,4 @@ test:
|
|||
enable_splunk_logging: false
|
||||
|
||||
production:
|
||||
single_process_mode: false
|
||||
|
|
|
|||
|
|
@ -1,5 +1,20 @@
|
|||
require File.join(Rails.root, 'app', 'models', 'jobs', 'base')
|
||||
Dir[File.join(Rails.root, 'app', 'models', 'jobs', '*.rb')].each { |file| require file }
|
||||
#config = YAML::load(File.open("#{Rails.root}/config/redis.yml"))
|
||||
#Resque.redis = Redis.new(:host => config['host'], :port => config['port'])
|
||||
|
||||
require 'resque'
|
||||
|
||||
begin
|
||||
if AppConfig[:single_process_mode]
|
||||
if Rails.env == 'production'
|
||||
puts "WARNING: You are running Diaspora in production without Resque workers turned on. Please don't do this."
|
||||
end
|
||||
|
||||
module Resque
|
||||
def enqueue(klass, *args)
|
||||
klass.send(:perform, *args)
|
||||
end
|
||||
end
|
||||
end
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
|
|
|
|||
|
|
@ -60,11 +60,19 @@ module Diaspora
|
|||
|
||||
module Socketable
|
||||
def socket_to_user(user_or_id, opts={})
|
||||
SocketsController.new.outgoing(user_or_id, self, opts)
|
||||
begin
|
||||
SocketsController.new.outgoing(user_or_id, self, opts)
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def unsocket_from_user(user_or_id, opts={})
|
||||
SocketsController.new.outgoing(user_or_id, Retraction.for(self), opts)
|
||||
begin
|
||||
SocketsController.new.outgoing(user_or_id, Retraction.for(self), opts)
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -121,7 +121,6 @@ if [ -n "$services" ]; then
|
|||
exit 64
|
||||
fi
|
||||
|
||||
|
||||
redis_config
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -63,4 +63,11 @@ describe Diaspora::Socketable do
|
|||
Diaspora::WebSocket.should_receive(:queue_to_user)
|
||||
@post.socket_to_user(@user, :aspect_ids => @aspect.id)
|
||||
end
|
||||
|
||||
it 'no-ops if redis isnt present' do
|
||||
Diaspora::WebSocket.stub(:redis).and_return(nil)
|
||||
lambda {
|
||||
@post.socket_to_user(@user, :aspect_ids => @aspect.id)
|
||||
}.should_not raise_error
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue