1

我正在使用 sidekiq Pro,通常会在他们的 Web UI 上监控我的工作人员的流程。每当出现错误时,任务都会移至重试选项卡,其中显示队列名称和错误消息。问题是我想在这条消息中添加数据(特别是类名和行号),但我还没有在任何地方找到关于这个的信息。是否可以编辑/配置 Web UI 显示?如果是这样,怎么办?

4

1 回答 1

1

是否可以编辑/配置 Web UI 显示?如果是这样,怎么办?

对的,这是可能的。获得额外监控信息的一种方法是构建自定义 UI 页面。您需要定义一个包含请求处理逻辑的模块并将该模块注册为 Sidekiq 网页:

module WebAddition
  def self.registered(app)
    app.get('/desired_path') do
      # you can define @instance_variables for passing into template
      # Sidekiq uses erb for its templates so you should do it aswell
      erb File.read(path_to_desired_erb_file)
    end 
  end
end

# here we instruct Sidekiq to take our UI extension onboard
Sidekiq::Web.register WebAddition
# in case you want to provide localization, it's achieved here
Sidekiq::Web.locales << File.expand_path(File.dirname(__FILE__) + "/web/locales")
# the name of your tab (at the left hand) gonna be translated
# using the provided locale file (if any).
# right hand of the equation should be equal to the path you specified
# in registered() method
Sidekiq::Web.tabs['disappeared_jobs'] = 'desired_path'

另一种选择(尽管强烈不推荐)可能是猴子补丁 Sidekiq UI 代码本身。查看Sidekiq WebApplication类,更改您感兴趣的方法并根据位于web/views文件夹中的 *.erb 文件进行更新。

于 2016-11-03T18:09:50.100 回答