From e35752d11ac0c8e01b4edc075d7f8928778185e8 Mon Sep 17 00:00:00 2001 From: Peter Deltchev Date: Sun, 17 Jan 2016 18:01:42 -0800 Subject: [PATCH] Prepared asynchronous jobs to run in daemon mode. --- app/Jobs/DeleteGenre.php | 3 +++ app/Jobs/EncodeTrackFile.php | 2 ++ app/Jobs/UpdateSearchIndexForEntity.php | 2 ++ app/Jobs/UpdateTagsForRenamedGenre.php | 3 +++ 4 files changed, 10 insertions(+) diff --git a/app/Jobs/DeleteGenre.php b/app/Jobs/DeleteGenre.php index 7e342ba5..e7bbc21f 100644 --- a/app/Jobs/DeleteGenre.php +++ b/app/Jobs/DeleteGenre.php @@ -21,6 +21,7 @@ namespace Poniverse\Ponyfm\Jobs; use Auth; +use DB; use Poniverse\Ponyfm\Models\Genre; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Bus\SelfHandling; @@ -60,6 +61,8 @@ class DeleteGenre extends Job implements SelfHandling, ShouldQueue */ public function handle() { + DB::reconnect(); + // The user who kicked off this job is used when generating revision log entries. Auth::login($this->executingUser); diff --git a/app/Jobs/EncodeTrackFile.php b/app/Jobs/EncodeTrackFile.php index 095af8ae..d28f606c 100644 --- a/app/Jobs/EncodeTrackFile.php +++ b/app/Jobs/EncodeTrackFile.php @@ -85,6 +85,8 @@ class EncodeTrackFile extends Job implements SelfHandling, ShouldQueue */ public function handle() { + DB::reconnect(); + // Sanity-check: was this file just generated, or is it already being processed? if ($this->trackFile->status === TrackFile::STATUS_PROCESSING) { Log::warning('Track file #'.$this->trackFile->id.' (track #'.$this->trackFile->track_id.') is already being processed!'); diff --git a/app/Jobs/UpdateSearchIndexForEntity.php b/app/Jobs/UpdateSearchIndexForEntity.php index 21b32131..177cb1cf 100644 --- a/app/Jobs/UpdateSearchIndexForEntity.php +++ b/app/Jobs/UpdateSearchIndexForEntity.php @@ -20,6 +20,7 @@ namespace Poniverse\Ponyfm\Jobs; +use DB; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Database\Eloquent\Model; use Illuminate\Queue\InteractsWithQueue; @@ -51,6 +52,7 @@ class UpdateSearchIndexForEntity extends Job implements SelfHandling, ShouldQueu */ public function handle() { + DB::reconnect(); $this->entity->updateElasticsearchEntrySynchronously(); } } diff --git a/app/Jobs/UpdateTagsForRenamedGenre.php b/app/Jobs/UpdateTagsForRenamedGenre.php index 27e5b934..63484b79 100644 --- a/app/Jobs/UpdateTagsForRenamedGenre.php +++ b/app/Jobs/UpdateTagsForRenamedGenre.php @@ -22,6 +22,7 @@ namespace Poniverse\Ponyfm\Jobs; use Auth; use Cache; +use DB; use Log; use Poniverse\Ponyfm\Models\Genre; use Illuminate\Queue\InteractsWithQueue; @@ -66,6 +67,8 @@ class UpdateTagsForRenamedGenre extends Job implements SelfHandling, ShouldQueue */ public function handle() { + DB::reconnect(); + // The user who kicked off this job is used when generating revision log entries. Auth::login($this->executingUser);