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!
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.
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:*
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With