请原谅我的无知,但是是否可以增加 Resque 工作人员每个 dyno 的进程数?如果是这样,如何?
我目前正在使用 Unicorn 向 Web dynos 添加并发性,到目前为止它一直运行良好。我想将此扩展到 Resque 工人。我按照Heroku 的指南来设置并发。
我有这个小的ruby应用程序,而不是Ruby on Rails - 纯Ruby.
我按照说明操作,我可以排队,看看所有内容都正确排队使用resque-web.
但是,我有一个问题,即开始一个工人.文档指示运行bin/resque work以启动工作程序.
这样做会触发消息 -bash: bin/resque: No such file or directory
在互联网上的每个地方,人们都有同样的问题,但对于Rails应用程序,不是纯粹的Ruby.解决方案似乎包含rakefile中的一些东西,我没有.
我怎样才能启动我的工作人员?非常感谢!
我创建了一个 docker 环境,它创建了 3 个图像:rails、postgresql 和 redis。它一直运行良好,但我发现我的 redis 映像似乎没有任何工作人员在运行。
我的 docker-compose.yml 如下
web:
build: .
command: bundle exec unicorn -p 3000 -c config/unicorn.rb
volumes:
- .:/fitmo
- ../fitmo-core:/fitmo-core
ports:
- "3000:3000"
links:
- db
- redis
environment:
- REDIS_URL=redis://redis:6379
db:
build: ./db/docker-files
ports:
- "5432"
redis:
image: redis:2.8
ports:
- "6379"
Run Code Online (Sandbox Code Playgroud)
require 'resque'
require 'resque-scheduler'
require 'resque_scheduler/server'
require 'appsignal/integrations/resque'
require 'yaml'
if Rails.env.test?
require 'mock_redis'
$redis = MockRedis.new
else
uri = URI.parse(ENV['REDIS_URL'])
$redis = Redis.new(host: uri.host, port: uri.port, …Run Code Online (Sandbox Code Playgroud) 我收到以下Redis错误:
MICONF Redis 配置为保存 RDB 快照,但目前无法在磁盘上持久化。
但是,它与权限无关,因为它仅在重新启动后的特定时间开始发生(最近一次发生在重新启动后大约一天)。当它发生时,服务器有足够的内存和磁盘空间。有什么建议?谢谢。
编辑:正确保存时,Redis 日志会显示这一点:
[2354] 11 月 13 日 09:56:16.071 * 300 秒内发生 10 次变化。保存...
[2354] 11 月 13 日 09:56:16.072 * 后台保存由 pid 2194 开始
[2194] 11 月 13 日 09:56:16.118 * 数据库保存在磁盘上
[2194] 11 月 13 日 09:56:16.118 * RDB:写时复制使用的 0 MB 内存
[2354] 11 月 13 日 09:56:16.172 * 后台保存成功终止
当错误发生时:
[2355] 11 月 13 日 09:15:12.069 * 1 在 900 秒内发生变化。保存...
[2355] 11 月 13 日 09:15:12.070 * 后台保存由 pid 27899 …
我在 Puma 服务器上有一个 Rails 4 应用程序,其中 Resque/Resque-Scheduler 正在运行后台作业。我想知道的是如何将两个 Resque 工作人员的日志输出合并到我的服务器日志中,或者,这是不可能的,我如何查看我的 Resque 工作人员的日志输出。目前我无法弄清楚如何查看工作人员的日志输出,所以我不知道幕后发生了什么。我找到了这篇博文,它建议将以下内容添加到我的resque.rake文件中:
task "resque:setup" => :environment do
Resque.before_fork = Proc.new {
ActiveRecord::Base.establish_connection
# Open the new separate log file
logfile = File.open(File.join(Rails.root, 'log', 'resque.log'), 'a')
# Activate file synchronization
logfile.sync = true
# Create a new buffered logger
Resque.logger = ActiveSupport::BufferedLogger.new(logfile)
Resque.logger.level = Logger::INFO
Resque.logger.info "Resque Logger Initialized!"
}
end
Run Code Online (Sandbox Code Playgroud)
那行不通。我还尝试了评论中的建议,即替换为Resque.logger = ActiveSupport::BufferedLogger.new(logfile),Resque.logger = ActiveSupport::Logger.new(logfile)但这也不起作用。使用第二个选项,当我NoMethodError: undefined method 'logger=' for Resque:Module尝试启动工作程序时仍然收到错误。 …
logging ruby-on-rails resque ruby-on-rails-4 resque-scheduler
我正在使用带有resque的Rails.
"睡眠时间"是指工作人员在找不到任何新任务后休息的秒数.
工作人员是由创建的QUEUE=* rake environment resque:work,默认值是5s,我不能将其更改为2s.
我已经搜索了几个小时这个问题,有人可以帮帮我吗?
Resque正在返回Mysql2 ::错误:关闭MySQL连接:SHOW FIELDS FROM users
Worker
8608f362-819b-4c15-b42b-69c4df00d27b:1 on low at about 16 hours ago
Class
AddLiveView
Arguments
4383
{"remote_ip"=>"184.72.47.71", "expires"=>true}
Exception
ActiveRecord::StatementInvalid
Error
Mysql2::Error: closed MySQL connection: SHOW FIELDS FROM `users`
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/mysql2_adapter.rb:283:in `query'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/mysql2_adapter.rb:283:in `block in execute'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract_adapter.rb:244:in `block in log'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract_adapter.rb:239:in `log'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/mysql2_adapter.rb:283:in `execute'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/mysql2_adapter.rb:473:in `columns'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:95:in `block (2 levels) in initialize'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:185:in `with_connection'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:92:in `block in initialize'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:106:in `yield'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:106:in `default'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:106:in `block in initialize'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/base.rb:717:in `yield'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/base.rb:717:in `default'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/base.rb:717:in `columns_hash'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/locking/optimistic.rb:145:in `locking_enabled?'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/relation.rb:110:in `to_a'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/relation/finder_methods.rb:376:in …Run Code Online (Sandbox Code Playgroud) 任何人都能指出我如何开始运行的解决方案
bundle exec env rake resque:work QUEUE='*'
Run Code Online (Sandbox Code Playgroud)
在生产中部署Rails应用程序时(我使用的是EC2和Ubuntu)?我没有使用乘客或任何部署(必须手动设置服务器,并且由于一些复杂情况,只需手动复制Rails应用程序).
我使用resque在后台运行一些作业,客户端(用户)通过在浏览器中对Web应用程序执行操作来启动这些作业.
问题是触发操作需要几秒钟.怎么能加快速度呢?我需要resque来更快地响应.
IM使用所有默认设置和配置没有修改.是否有任何关于配置或建议的指导方针,以便更快地进行resque响应?
我和一个工人一起运行,一次只有1,2个队列.
我有一个基于Web的应用程序,我使用Sinatra构建.从最近起,我需要定期收集数据并将它们存储在数据库中.为此我被告知我可以使用Resque和Clockwork宝石结合.
每隔一小时左右,我需要根据数据库进行近15次计算,并将结果存储在数据库中.
所以这就是我采取的方法.我决定制作15个具有该perform方法的类(我用于测试的确切文件如下).然后Resque.enqueue( GraphData )为所有15个类做一些类似的事情.
class GraphData
@queue = :graph_data
def self.init()
end
def self.perform()
File.open( '/home/ziyan/Desktop/resque.txt', 'a' ) { | file | file.write( "Resqueu - performed - #{Time.now}\n" ) }
end
end
Run Code Online (Sandbox Code Playgroud)
为了触发测试操作,我创建了一个rake任务.
desc "Start Resque Workers for Queue" # {{{
task :graph_data do |t|
ENV["QUEUE"] = "*"
ENV["VVERBOSE"] = "1"
ENV["INTERVAL"] = "5"
Resque.enqueue( GraphData )
#resque = Resque.new
#resque << AdminWorker.new
end # }}}
Run Code Online (Sandbox Code Playgroud)
如你所见,在GraphData类中,self.perform我正在写一个文件. …
resque ×10
redis ×3
ruby ×2
amazon-ec2 ×1
docker ×1
dockerfile ×1
heroku ×1
logging ×1
performance ×1
rake ×1
ubuntu ×1
unicorn ×1