From 852dbcb50e259b45def6c6aeeb3dcbdc20b8c2d1 Mon Sep 17 00:00:00 2001 From: Database Server Date: Tue, 8 Nov 2022 09:44:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E4=B8=80=E7=9B=B4=E5=9C=A8=20pending=20=E7=9A=84=E4=B8=BB?= =?UTF-8?q?=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Jobs/DeleteHost.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/Jobs/DeleteHost.php b/app/Jobs/DeleteHost.php index 4f68f8c..192f7ad 100644 --- a/app/Jobs/DeleteHost.php +++ b/app/Jobs/DeleteHost.php @@ -39,5 +39,12 @@ public function handle() dispatch(new \App\Jobs\Remote\Host($host, 'delete')); } }); + + // 查找部署时间超过3天以上的 host + Host::where('status', 'pending')->where('created_at', '<', now()->subDays(3))->chunk(100, function ($hosts) { + foreach ($hosts as $host) { + dispatch(new \App\Jobs\Remote\Host($host, 'delete')); + } + }); } }