I am trying to queue the artisan command in the Laravel 5.8 version. But Job entry in the database table is not deleting automatically.
I tried the following things.
1. Directly Dispatch the artisan command as per documentation here
Artisan::queue('set:store_permissions', [
'app_id' => 1,
'user_id' => 1
])->onConnection('database')->onQueue('upgrade_for_permissions');
2. Create Job and dispatch it and in Job Call Artisan command.
[Dispatching]
$d_t_s = new \stdClass();
$d_t_s->id = 1;
UpgradeDatabaseForPermissions::dispatch($d_t_s)->onConnection('database')->onQueue('upgrade_for_permissions');
[Job calls Artisan Command]
protected $user_id;
public $tries = 5;
public function __construct($d) {
$this->user_id = $d->id;
//
}
public function handle() {
$user_id = $this->user_id;
Storage::disk('local')->append('upgrade_permission.log', "Started :: user :: " . $user_id);
$artisan = Artisan::call('set:store_permissions', [
'app_id' => 1,
'user_id' => $user_id
]);
Storage::disk('local')->append('upgrade_permission.log', "End :: user :: " . $user_id . ' :: ');
return true;
}
Both of them work perfectly the issue is Job entry is not deleting from the database automatically.
If I remove the Artisan::call from the Job It will automatically removed from the database.
I also tried to return true from the command itself and Job as well but none of them worked.
When I run
php artisan queue:work database --queue="upgrade_for_permissions"
It outputs as follows
[2019-10-03 16:22:51][1] Processing: App\Jobs\UpgradeDatabaseForPermissions
[2019-10-03 16:22:52][1] Processed: App\Jobs\UpgradeDatabaseForPermissions
But does not delete the queue entry itself from the database table. This only happens if I run artisan command in it.
Any suggestions will be helpful.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire