0

I want to run the queue:listen --tries command outside of artisan cli. For that i have written a function "task" in WelcomeController and called it through routes. However it generates the above error. Codes are given below:

public function task()
{

    Artisan::call('queue:listen', ['--tries'=>'3']);
}

Routes as follows

Route::post('/fun', array('uses'=>'WelcomeController@task'));
Joey Ciechanowicz
  • 3,345
  • 3
  • 24
  • 48
  • MethodNotAllowedHttpException is thrown whenever you don't match the method type when you access the route. So if you use `GET` request to a `POST` route you will get this error. So the `Artisan` call is never invoked. – nakov Mar 28 '19 at 11:42
  • but getting it change to get, couldnt run the code. and the 60s loading time error generates...so if you can guide – Faran Rana Mar 28 '19 at 11:47
  • you are not returning anything from the controller method. Try at the bottom of the method `return 'Ok';` having `get` as a method type, and then use the browser – nakov Mar 28 '19 at 11:49
  • so . i changed it to Route::get('/fun', 'WelcomeController@task'); ,but it throws Maximum execution time of 60 seconds exceeded – Faran Rana Mar 28 '19 at 11:49
  • did you tried returning something from the method? That's what I wrote above – nakov Mar 28 '19 at 11:51
  • i did return ok but same error of 60s timeout – Faran Rana Mar 28 '19 at 11:52
  • public function task() { Artisan::call('queue:listen', ['--tries'=>'3']); return 'ok'; } – Faran Rana Mar 28 '19 at 11:52
  • The problem is because the `queue:listen` is a foreground job, so it listens to the queue without stopping, that's why it is hanging – nakov Mar 28 '19 at 11:53
  • There are some answers here https://stackoverflow.com/questions/28623001/how-to-keep-laravel-queue-system-running-on-server to run it in the background – nakov Mar 28 '19 at 11:54

0 Answers0