Search code examples
laravellaravel-5laravel-echo

Laravel echo server killed on exit console


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!


Solution

  • 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:*