gpt4 book ai didi

linux - 如何优雅地停止作为 docker 镜像运行的 Laravel Queueworker?

转载 作者:行者123 更新时间:2023-12-02 18:05:32 24 4
gpt4 key购买 nike

我们正在 Kubernetes 上部署 Laravel 应用程序。只是应用程序不是问题,但队列工作人员是。我们从多个来源了解到,建议将 queueworkers 作为单独的 Deployment 运行。因此,在 kubeconfig 部分下面,它作为命令运行队列 worker 。 php artisan 队列:工作

我知道它作为 PID1 运行。所以当进程崩溃时,Kubernetes 会自动重启 pod。然而,问题是,当我们删除 pod 时,它需要一段时间(大约 20 秒)才能停止,并且它以退出代码 137 而不是 0 退出。当我 exec 进入 pod 时,我可以看到这一点。它在删除时返回 terminated with exit code 137

关于 this article我读到 Laravel(我们使用的是 7.x)是异步的,应该对 SIGTERM 信号使用react。那么,当我们停止 pod 时,kubernetes 正在发送一个 SIGTERM 信号,并且应该优雅地停止 pod,这难道不符合逻辑吗?优雅地应该是 exitcode 0,对吧?

我希望任何人都可以解释我在这里做错了什么。

apiVersion: apps/v1
kind: Deployment
metadata:
namespace: hip-prod
name: worker
labels:
worker: worker
spec:
minReadySeconds: 5
replicas: 1
revisionHistoryLimit: 1
selector:
matchLabels:
worker: worker
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 50%
type: RollingUpdate
template:
metadata:
labels:
worker: worker
spec:
nodeSelector:
"beta.kubernetes.io/os": linux
containers:
- name: worker
image: my-laravel-image/app:latest
command: ["php", "artisan", "queue:work"]
imagePullPolicy: Always

最佳答案

你试过用这个构建你的 docker-image 吗?

STOPSIGNAL SIGTERM

关于linux - 如何优雅地停止作为 docker 镜像运行的 Laravel Queueworker?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62446226/

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