R
R
RookDeveloper2019-08-17 20:54:07
Laravel
RookDeveloper, 2019-08-17 20:54:07

Why can't I run the php artisan + workerman command?

Good evening everyone! But for me, he is not good at all!
I have a console command on the lara, and here is the handle:

public function handle()
    {
        $ws_worker = new Worker("websocket://...:8080");

        $ws_worker->count = 4;

        $this->clients = new \SplObjectStorage();

        $ws_worker->onWorkerStart = function ($ws_worker) {};

        $ws_worker->onConnect = function ($connection) {};

        $ws_worker->onMessage = function ($connection, $data_request) {};

        $ws_worker->onClose = function ($connection) {};

        Worker::runAll();
    }

I run the command on debugging (on a local server, not on Windows)... everything is ok... everything is super...
BUT... I run it already on production (ubuntu), there is an error, they say another parameter is needed, the command is not defined (namely, workerman swears:
5d583df7b6731840488117.png
What should I do? I tried to prescribe additional fields in the command parameters through Lara:
protected $signature = 'vklike:listen {mode}';
It's useless...nothing works...but the solution was found...
Inside the handle write:
public function handle()
    {
        global $argv;
        $argv[1] = 'start';

        $ws_worker = new Worker("websocket://...:8080");

        $ws_worker->count = 4;

        $this->clients = new \SplObjectStorage();

        $ws_worker->onWorkerStart = function ($ws_worker) {};

        $ws_worker->onConnect = function ($connection) {};

        $ws_worker->onMessage = function ($connection, $data_request) {};

        $ws_worker->onClose = function ($connection) {};

        Worker::runAll();
    }

Everything is OK, it starts, but it behaves very strangely. It's as if a separate socket listener is created for each connection...
On debugging, everything is like clockwork...everything works....
Please help...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RookDeveloper, 2019-08-18
@RookDeveloper

Everything is done right! Just needed to set $ws_worker->count = 1.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question