Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Best Practice Running Laravel Echo Server as Background Service #65

Closed
bendo01 opened this issue Oct 29, 2016 · 19 comments
Closed

Best Practice Running Laravel Echo Server as Background Service #65

bendo01 opened this issue Oct 29, 2016 · 19 comments

Comments

@bendo01
Copy link

bendo01 commented Oct 29, 2016

hi, i want to ask
are there any best practice using Laravel Echo Server On Production Server as background service
like queue process on laravel documentation suggestion using supervisord,
is Laravel Echo Server can be run with pm2 or nodaemon?
thanks a lot

@feenx
Copy link

feenx commented Oct 30, 2016

I'm running it with supervisor right now. Working perfectly for me, on my production server I've done the same except I had to use an absolute path to node in order to get the global installation of this package to fire up properly but it works great now.

@bendo01
Copy link
Author

bendo01 commented Oct 30, 2016

@pfeiferchristopher Thank You, I Will Try It With Supervisor

@jonnywilliamson
Copy link
Contributor

Here's a copy of the supervisor config file I have for my echo server for a rough guideline (on a vagrant machine)

[program:echo-server]
directory=/home/vagrant/path/to/your/project
command=/usr/bin/laravel-echo-server start
autostart=true
autorestart=true
user=vagrant
redirect_stderr=true
stdout_logfile=/home/vagrant/path/to/your/project/storage/logs/echoserver.log

@andkom
Copy link

andkom commented Nov 7, 2016

example pm2 configuration:

echo.json:

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

command:

pm2 start echo.json

@jonnywilliamson
Copy link
Contributor

@andkom Just to clarify though, using PM2 doesn't help with regard restarting the process if it exits? You'd still need supervisor/upstart etc?

@trip-somers
Copy link

Is there a way to kill/restart the Laravel Echo Server when/if a new configuration goes live? This would be something akin to how Laravel allows you to restart your queue workers: php artisan queue:restart

@trip-somers
Copy link

Does no one ever need to restart their Echo server?

@andkom
Copy link

andkom commented Jan 16, 2017

@jonnywilliamson

pm2 restart echo

will restart echo process

@barryvdh
Copy link
Contributor

You can also just restart with supervisor. Don't know if there is a 'graceful' restart, but with the latest echo, the clients should just reconnect when the server is back.

@trip-somers
Copy link

Thanks, @barryvdh. I finally had time to look into that. I probably should have looked there first.

@ThunderBirdsX3
Copy link

@andkom How to call with config file laravel-echo-server.json

@catalinux
Copy link

That json config file it will be loaded by default. You need to run the server in the directory where the config file is placed

@wa05
Copy link

wa05 commented Sep 15, 2017

I cant set PM2 (2.6.1) on Windows 7 with Node v8.1.4

PM2 Log:

C:\USERS\WALTER\APPDATA\ROAMING\NPM\LARAVEL-ECHO-SERVER.CMD:1
(function (exports, require, module, __filename, __dirname) { @if EXIST "%~dp0\node.exe" (
^
SyntaxError: Invalid or unexpected token
at createScript (vm.js:74:10)
at Object.runInThisContext (vm.js:116:10)
at Module._compile (module.js:533:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Object. (C:\Users\Walter\AppData\Roaming\npm\node_modules\pm2\lib\ProcessContainerFork.js:70:21)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)

I'll try to run laravel-echo-server from a .bat and start the .bat with the Windows task scheduler or try to make work Supervisord on Windows creating a service with cygwin and python.. :/

1

@jartaud
Copy link

jartaud commented Dec 6, 2017

Same as @wa05 comment

Node: v8.9.1
Npm: 5.5.1
Win10

@wa05
Copy link

wa05 commented Dec 6, 2017

@jartaud tell me if you can run the daemon with this https://github.com/coreybutler/node-windows

@anddyyao
Copy link

Same as @wa05
why

@KrzysztofHajdamowicz
Copy link

Systemd unit:

[Unit]
Description=Start a laravel-echo-server
After=network.target

[Service]
User=USER
Group=GROUP
WorkingDirectory=/var/lib/html/project
ExecStart=/usr/bin/laravel-echo-server start

Restart=on-failure

[Install]
WantedBy=multi-user.target

@wa05
Copy link

wa05 commented Jun 27, 2018

Finally Im running it with windows task manager..

@peters305
Copy link

You can also just restart with supervisor. Don't know if there is a 'graceful' restart, but with the latest echo, the clients should just reconnect when the server is back.

Hey Barry if you don't mind its little bit late but i was asking i want to start laravel-echo-server but i have dist folder after running npm build which includes index.html file how can start this

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests