在localhost上连接到Redis时出错:6379(Errno :: ECONNREFUSED)(Redis :: CannotConnectError)

时间:2017-12-05 10:10:02

标签: ruby-on-rails

我尝试连接到reddis On c9.io 但是得到这个错误

/usr/local/rvm/gems/ruby-2.4.0/gems/redis-4.0.1/lib/redis/client.rb:344:in `rescue in establish_connection': Error connecting to Redis on localhost:6379 (Errno::ECONNREFUSED) (Redis::CannotConnectError)
        from /usr/local/rvm/gems/ruby-2.4.0/gems/redis-4.0.1/lib/redis/client.rb:329:in `establish_connection'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/redis-4.0.1/lib/redis/client.rb:99:in `block in connect'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/redis-4.0.1/lib/redis/client.rb:291:in `with_reconnect'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/redis-4.0.1/lib/redis/client.rb:98:in `connect'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/redis-4.0.1/lib/redis/client.rb:363:in `ensure_connected'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/redis-4.0.1/lib/redis/client.rb:219:in `block in process'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/redis-4.0.1/lib/redis/client.rb:304:in `logging'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/redis-4.0.1/lib/redis/client.rb:218:in `process'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/redis-4.0.1/lib/redis/client.rb:118:in `call'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/redis-4.0.1/lib/redis.rb:1330:in `block in sadd'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/redis-4.0.1/lib/redis.rb:45:in `block in synchronize'
        from /usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/redis-4.0.1/lib/redis.rb:45:in `synchronize'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/redis-4.0.1/lib/redis.rb:1329:in `sadd'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/redis-namespace-1.6.0/lib/redis/namespace.rb:442:in `call_with_namespace'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/redis-namespace-1.6.0/lib/redis/namespace.rb:328:in `method_missing'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/resque-1.27.4/lib/resque/data_store.rb:59:in `method_missing'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/resque-scheduler-4.3.1/lib/resque/scheduler/scheduling_extensions.rb:94:in `set_schedule'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/resque-scheduler-4.3.1/lib/resque/scheduler/scheduling_extensions.rb:51:in `block in schedule='
        from /usr/local/rvm/gems/ruby-2.4.0/gems/resque-scheduler-4.3.1/lib/resque/scheduler/scheduling_extensions.rb:50:in `each'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/resque-scheduler-4.3.1/lib/resque/scheduler/scheduling_extensions.rb:50:in `schedule='
        from /home/ubuntu/workspace/UnicumParser/config/initializers/resque.rb:4:in `<top (required)>'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:287:in `load'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:287:in `block in load'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:287:in `load'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/engine.rb:648:in `block in load_config_initializer'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/activesupport-5.0.1/lib/active_support/notifications.rb:166:in `instrument'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/engine.rb:647:in `load_config_initializer'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/engine.rb:612:in `block (2 levels) in <class:Engine>'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/engine.rb:611:in `each'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/engine.rb:611:in `block in <class:Engine>'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/initializable.rb:30:in `instance_exec'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/initializable.rb:30:in `run'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/initializable.rb:55:in `block in run_initializers'
        from /usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:228:in `block in tsort_each'
        from /usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
        from /usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
        from /usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:431:in `each_strongly_connected_component_from'
        from /usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/initializable.rb:44:in `each'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/initializable.rb:44:in `tsort_each_child'
        from /usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:415:in `call'
        from /usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:415:in `each_strongly_connected_component_from'
        from /usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:349:in `block in each_strongly_connected_component'
        from /usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:347:in `each'
        from /usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:347:in `call'
        from /usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:347:in `each_strongly_connected_component'
        from /usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:226:in `tsort_each'
        from /usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:205:in `tsort_each'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/initializable.rb:54:in `run_initializers'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/application.rb:352:in `initialize!'
        from /home/ubuntu/workspace/UnicumParser/config/environment.rb:5:in `<top (required)>'
        from /home/ubuntu/workspace/UnicumParser/config.ru:3:in `require_relative'
        from /home/ubuntu/workspace/UnicumParser/config.ru:3:in `block in <main>'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/rack-2.0.3/lib/rack/builder.rb:55:in `instance_eval'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/rack-2.0.3/lib/rack/builder.rb:55:in `initialize'
        from /home/ubuntu/workspace/UnicumParser/config.ru:in `new'
        from /home/ubuntu/workspace/UnicumParser/config.ru:in `<main>'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/rack-2.0.3/lib/rack/builder.rb:49:in `eval'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/rack-2.0.3/lib/rack/builder.rb:49:in `new_from_string'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/rack-2.0.3/lib/rack/builder.rb:40:in `parse_file'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/rack-2.0.3/lib/rack/server.rb:319:in `build_app_and_options_from_config'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/rack-2.0.3/lib/rack/server.rb:219:in `app'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/commands/server.rb:59:in `app'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/rack-2.0.3/lib/rack/server.rb:354:in `wrapped_app'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/commands/server.rb:124:in `log_to_stdout'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/commands/server.rb:77:in `start'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:90:in `block in server'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:85:in `tap'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:85:in `server'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/commands.rb:18:in `<top (required)>'
        from /home/ubuntu/workspace/UnicumParser/bin/rails:9:in `require'
        from /home/ubuntu/workspace/UnicumParser/bin/rails:9:in `<top (required)>'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
        from /usr/local/rvm/gems/ruby-2.4.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
        from /home/ubuntu/workspace/UnicumParser/bin/spring:14:in `require'
        from /home/ubuntu/workspace/UnicumParser/bin/spring:14:in `<top (required)>'
        from bin/rails:3:in `load'
        from bin/rails:3:in `<main>'

resque.rb文件:

require 'resque'
require 'resque/scheduler'

Resque.schedule = YAML.load_file(File.join(Rails.root, 'config/resque_schedule.yml'))
Resque.logger = Logger.new(Rails.root.join('log', "#{Rails.env}_resque.log"))
Resque.logger.level = Logger::INFO

rails_env = ENV['RAILS_ENV'] || 'development'
Resque.redis.namespace = "resque:#{rails_env}"

0 个答案:

没有答案