[英]RoR + Node.js Redis sub/pub on production
I have some trouble with Redis pub/sub in RoR on production mode. 我在生产模式下在RoR中使用Redis pub / sub遇到一些麻烦。
I have 3 instance: RoR server, Node server and Rake task and Model in some state (Model state 1) 我有3个实例:RoR服务器,节点服务器以及Rake任务和处于某种状态的模型(模型状态1)
RoR server updates Model with id = 1 and publish event 'one' to Redis. RoR服务器更新ID = 1的模型,并将事件“一”发布到Redis。 (Model state 2)
(模型状态2)
Node.js server subscribed to Redis event 'one' gets message, doing something and publish event 'two' to Redis with some data 订阅Redis事件'one'的Node.js服务器获取消息,执行某些操作,然后将事件'two'发布给Redis,并提供一些数据
Some time later: 一段时间之后:
It is observed only in the case of production mode. 仅在生产模式下可以观察到。 In development mode rake task gets Model state 3 and everything is ok.
在开发模式下,rake任务变为Model状态3,一切正常。
development.rb development.rb
Rails.application.configure do
config.cache_classes = false
config.eager_load = false
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_mailer.raise_delivery_errors = false
config.active_support.deprecation = :log
config.active_record.migration_error = :page_load
config.assets.debug = true
config.assets.digest = true
config.assets.raise_runtime_errors = true
end
production.rb production.rb
Rails.application.configure do
config.cache_classes = true
config.eager_load = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.serve_static_files = true
config.assets.js_compressor = :uglifier
config.assets.compile = true
config.assets.digest = true
config.log_level = :debug
config.i18n.fallbacks = true
config.active_support.deprecation = :notify
config.log_formatter = ::Logger::Formatter.new
config.active_record.dump_schema_after_migration = false
end
解决了在生产模式下启动rake任务的问题
bundle exec rake some:task RAILS_ENV=production
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.