ruby-on-rails – GKE kubernetes delayed_job pod日志

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – GKE kubernetes delayed_job pod日志前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个带有以下rake作业的部署对象:work命令:
apiVersion: extensions/v1beta1
kind: Deployment
Metadata:
  name: staging-delayed-job-deployment
  namespace: staging
spec:
  template:
    Metadata:
      labels:
        env: staging
        name: delayed-job
    spec:
      containers:
        - name: job
          image: gcr.io/ej-gc-dev/redacted:<%= ENV['IMAGE_TAG'] %>
          command: ["/bin/bash","-l","-c"]
          args: ["RAILS_ENV=production bundle exec rake jobs:work"]

当我运行kubectl日志时,我什么都没得到.如何获得rake作业:工作输出显示在kubectl日志中?即如果直接在pod中运行,它会提供如下输出

[Worker(host:staging-deployment-cc7dc559f-bswvr pid:2381)] Starting job worker
[Worker(host:staging-deployment-cc7dc559f-bswvr pid:2381)] Job UpdateHubspotPersonaJob (id=67) RUNNING
[Worker(host:staging-deployment-cc7dc559f-bswvr pid:2381)] Job UpdateHubspotPersonaJob (id=67) COMPLETED after 0.4903
[Worker(host:staging-deployment-cc7dc559f-bswvr pid:2381)] Job Mailerjack.registration_created_user_welcome (id=68) RUNNING
[Worker(host:staging-deployment-cc7dc559f-bswvr pid:2381)] Job Mailerjack.registration_created_user_welcome (id=68) COMPLETED after 0.9115
[Worker(host:staging-deployment-cc7dc559f-bswvr pid:2381)] Job UpdateHubspotPersonaJob (id=69) RUNNING
[Worker(host:staging-deployment-cc7dc559f-bswvr pid:2381)] Job UpdateHubspotPersonaJob (id=69) COMPLETED after 0.1752
[Worker(host:staging-deployment-cc7dc559f-bswvr pid:2381)] Job Mailerjack.registration_created_user_welcome (id=70) RUNNING
[Worker(host:staging-deployment-cc7dc559f-bswvr pid:2381)] Job Mailerjack.registration_created_user_welcome (id=70) COMPLETED after 0.4770
[Worker(host:staging-deployment-cc7dc559f-bswvr pid:2381)] 4 jobs processed at 1.7649 j/s,0 Failed

当我运行kubectl日志时,我希望它出现

解决方法

我需要添加一个初始化器:config / initializers / delayed_job.rb并将worker的logger设置为stdout,如下所示:

延迟:: Worker.logger = Logger.new(STDOUT)

原文链接:https://www.f2er.com/ruby/270259.html

猜你在找的Ruby相关文章