How to run laravel echo server forever

How to run laravel echo server forever

2,614

In this article, I’ll briefly show you how to quickly whip up a working socket server and broadcast events over the server forever

Note: this article is not about how to setup laravel echo or redis, nor socket-io in this article I only teach you how to run your echo socket forever.
-For setup laravel echo and socket-io I’ll probably will publish another article to cover full details of it but let see responses to this article first :).


Well let’s begin:

First thing first:

install pm2 on your server root (https://pm2.keymetrics.io/)

make new file:

I’d like to name it echo-pm2.json you can name it whatever you like.

Copy this code into it and save.

{
  "name": "echo",
  "script": "laravel-echo-server.json",
  "args": "start"
}

Upload the file:

Upload echo-pm2.json in root folder of your laravel application (same place as laravel-echo-server.json is).

Open your terminal:

Go to your application root and paste this command

pm2 start echo-pm2.json

To test your running script use this command:

pm2 list

You should see your script is marked as Online status.

In order to stop script run this command:

pm2 stop echo-pm2.json

That’s all you need.


Troubleshooting:

In case after this process you still receive net::ERR_TIMED_OUT error you might be on wrong URL. (double check your URL for http/https)

Source

- Last updated 3 years ago

Be the first to leave a comment.

You must login to leave a comment