phplaravelwebsocketbinanceratchet

How to use PHP Laravel Binance web sockets?


In Laravel I made a test command and following this example implemented websocket client. It runs fine, but I am clueless how to launch it on server.

Controller? Does it keep running after page is loaded? Command? Does it keep running after ctrl+c? scheduler? Wont it launch new instance alongside existing ones every time?

Should I run it with supervisord? if so, should it be a command

[program:websockets]
command=php /var/www/laravel-app/artisan websocket_client:work
numprocs=1
autostart=true
autorestart=true
user=laravel-echo

or command=php /var/www/laravel-app/app/WebsocktClients/Binance.php?

How should I go about this?


Solution

  • The right answer was supervisord. Also I had to add some lines to throw exceptions when connection is closed to force worker restart, otherwise it might take some time (even hour) for process to stop after connection has been closed.