我有一个带有以下rake jobs: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 logs
时,我什么都没得到。如何在rake jobs:work
中显示kubectl logs
输出?即如果直接在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 logs
答案 0 :(得分:3)
我需要添加一个初始化程序:config/initializers/delayed_job.rb
并将worker的记录器设置为stdout,如下所示:
Delayed::Worker.logger = Logger.new(STDOUT)