Prepared asynchronous jobs to run in daemon mode.

This commit is contained in:
Peter Deltchev 2016-01-17 18:01:42 -08:00
parent 23ae7ffa72
commit e35752d11a
4 changed files with 10 additions and 0 deletions

View file

@ -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);

View file

@ -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!');

View file

@ -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();
}
}

View file

@ -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);