mbg
mbg

Reputation: 53

run php artisan websockets:serve automatically without supervisor

i have a laravel project with beyondcode/laravel-websockets package.

Everytime i want to run the websockets, i need to run:

php artisan websockets:serve
I can't do this for producction.

I don't have access to the apache production server, so i can't install the supervisor package, all i can modify about the apache is my .htaccess file.

How can i run this command or something for start my websocket app automatically?

Upvotes: 2

Views: 9820

Answers (1)

mbg
mbg

Reputation: 53

I just made a route like this one for run the command

Route::group(['prefix' => 'internal', 'middleware' => ['jwt.verify','admin']], function(){
    Route::get('sockets/serve', function(){
        \Illuminate\Support\Facades\Artisan::call('websockets:serve');
    });
});

I don't know if its the best option but its working 100% fine, so I am satisfied. When the route is called, it keeps in an infinite time lapse, that's because the command is a listener and never returns a response, so the route will never return a response, just close the window or something else.

Thanks again to Huy Trịnh

Upvotes: 3

Related Questions