Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cron 如何使用默认队列在本地查看sidekiq控制台输出?_Cron_Console_Ruby On Rails 5_Sidekiq_Worker - Fatal编程技术网

Cron 如何使用默认队列在本地查看sidekiq控制台输出?

Cron 如何使用默认队列在本地查看sidekiq控制台输出?,cron,console,ruby-on-rails-5,sidekiq,worker,Cron,Console,Ruby On Rails 5,Sidekiq,Worker,我使用的是Rails 5。我想创建一个使用默认队列在本地运行的sidekiq进程。我的工人阶级大致如下所示 module Accounting::Workers class FileGenerationWorker include Sidekiq::Worker def perform print "starting work ...\n" ... 我已经像这样设置了我的config/sidekiq.yml文件,希望每天在特定的时间(上午11:05

我使用的是Rails 5。我想创建一个使用默认队列在本地运行的sidekiq进程。我的工人阶级大致如下所示

module Accounting::Workers
  class FileGenerationWorker
    include Sidekiq::Worker

    def perform
      print "starting work ...\n"
      ...
我已经像这样设置了我的config/sidekiq.yml文件,希望每天在特定的时间(上午11:05)运行worker

但是,当我启动rails服务器(“rails s”)时,我看不到控制台的打印语句输出,也看不到执行的任何工作,这说明我的工作人员没有运行。为了在本地正确安排此工作进程,我还缺少什么?

使用运行这些工作进程

bundle exec sidekiq
您可能需要提供工作模块的路径。比如说,

bundle exec sidekiq -r ./worker.rb
Sidekiq本身不支持中的
:schedule:
映射条目

功能在扩展中提供,例如

您需要使用
sidekiq调度程序中提供的中声明的类。比如说,

bundle exec sidekiq -r ./worker.rb
/worker.rb

require 'sidekiq-scheduler'

require './app/workers/accounting'

Sidekiq.configure_client do |config|
 config.redis = {db: 1}
end

Sidekiq.configure_server do |config|
 config.redis = {db: 1}
end
module Accounting
   # ...
end

module Accounting::Workers
  class FileGenerationWorker
    include Sidekiq::Worker

    def perform
      puts "starting work ...\n"
    end
  end
end

/app/workers/accounting.rb

require 'sidekiq-scheduler'

require './app/workers/accounting'

Sidekiq.configure_client do |config|
 config.redis = {db: 1}
end

Sidekiq.configure_server do |config|
 config.redis = {db: 1}
end
module Accounting
   # ...
end

module Accounting::Workers
  class FileGenerationWorker
    include Sidekiq::Worker

    def perform
      puts "starting work ...\n"
    end
  end
end