gpt4 book ai didi

ruby-on-rails - GKE kubernetes delay_job pod 日志

转载 作者:行者123 更新时间:2023-12-04 07:29:45 24 4
gpt4 key购买 nike

我有一个具有以下内容的部署对象 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

最佳答案

我需要添加一个初始化程序:config/initializers/delayed_job.rb并将 worker 的记录器设置为标准输出,如下所示:
Delayed::Worker.logger = Logger.new(STDOUT)

关于ruby-on-rails - GKE kubernetes delay_job pod 日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48826651/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com