Laravel echo server killed on exit console
Asked Answered
H

2

8

i'm using laravel-echo-server and all works fine, if i launch server with this command:

laravel-echo-server start

i see:

L A R A V E L E C H O S E R V E R

version 1.2.8

Starting server...

✔  Running at localhost on port 3001
✔  Channels are ready.
✔  Listening for http events...
✔  Listening for redis events...

Server ready!

But if i close with ctrl+c the server has been killed! the same things if i use this command:

laravel-echo-server start &

if i disconnect my ssh connection, the server stop work!

How can i launch in background mode?

thanks!

Heshvan answered 17/6, 2017 at 13:0 Comment(0)
L
4

Install Supervisor on linux. Here is a manual: https://laravel.com/docs/5.4/queues#supervisor-configuration

Here is my supervisor config file:

[program:websocket-server]
process_name=%(program_name)s
directory=/var/www/example.de/public_html/
command=/usr/lib/node_modules/laravel-echo-server/bin/server.js start
autostart=true
autorestart=true
user=www-data
numprocs=1
redirect_stderr=true
stdout_logfile=/var/www/example.de/logs/websocket-server.log

Now you can start the server in the background with supervisorctl start websocket-server:*

Liggett answered 17/6, 2017 at 13:31 Comment(0)
A
9

I recommend to use the pm2 tool to manage the larval-echo-server service. After install pm2 you must create a json file inside the Laravel project with a content like this:

echo-pm2.json

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

Then run the next command to start the service in background:

pm2 start echo-pm2.json

Yo can use pm2 monit command for real time monitoring or pm2 logs to get the service logs as well.

Areaway answered 15/7, 2019 at 14:37 Comment(1)
hi, this still return net::ERR_TIMED_OUTBohunk
L
4

Install Supervisor on linux. Here is a manual: https://laravel.com/docs/5.4/queues#supervisor-configuration

Here is my supervisor config file:

[program:websocket-server]
process_name=%(program_name)s
directory=/var/www/example.de/public_html/
command=/usr/lib/node_modules/laravel-echo-server/bin/server.js start
autostart=true
autorestart=true
user=www-data
numprocs=1
redirect_stderr=true
stdout_logfile=/var/www/example.de/logs/websocket-server.log

Now you can start the server in the background with supervisorctl start websocket-server:*

Liggett answered 17/6, 2017 at 13:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.