Skip to content

Commit 11fe192

Browse files
committed
Implement reconnect on db
1 parent 31d96ec commit 11fe192

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/AbstractJob.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Bus\Queueable;
66
use Illuminate\Contracts\Queue\ShouldQueue;
77
use Illuminate\Queue\InteractsWithQueue;
8+
use Illuminate\Queue\Jobs\SyncJob;
89
use Illuminate\Queue\SerializesModels;
910
use LaravelQueueManager\Repository\QueueConfigRepository;
1011

@@ -28,9 +29,22 @@ private function preventKillProcess()
2829
});
2930
}
3031

32+
private function reconnectDb()
33+
{
34+
if ($this->job instanceof SyncJob) {
35+
return;
36+
}
37+
38+
$connections = \Db::getConnections();
39+
foreach ($connections as $connectionName => $connection) {
40+
\Db::reconnect($connectionName);
41+
}
42+
}
43+
3144
final public function handle()
3245
{
3346
$this->preventKillProcess();
47+
$this->reconnectDb();
3448
$this->execute();
3549
}
3650

0 commit comments

Comments
 (0)