IJAZ ALI

VUE JS Developer

Laravel Developer

Freelancer

Full Stack Developer

IJAZ ALI

VUE JS Developer

Laravel Developer

Freelancer

Full Stack Developer

Blog Post

Run WebSocket Laravel Artisan Command in Supervisor

June 8, 2020 Linux, Ubuntu

Supervisor could be a client/server system that permits its users to watch and control variety of processes on UNIX-like operating systems.

It shares a number of an equivalent goals of programs like launchd, daemontools, and runit. Unlike a number of these programs, it’s not meant to be run as a substitute for init as “process id 1”. Instead it’s meant to be wont to control processes associated with a project or a customer, and is supposed to start out like all other program at boot time.

Official Website supervisord.org

If you haven’t install supervisor, you’ll install it first.

# Debian / Ubuntu:
$ sudo apt-get install supervisor

Next, we’ll configure it. We need to define a process to listen to.

$ sudo vim /etc/supervisor/conf.d/websocket.conf

Add this to your new conf file, changing file paths and your environment as necessary

[program:websocket]
command=php artisan websocket:init
directory=/path/to/laravel
stdout_logfile=/path/to/laravel/app/storage/logs/websocket_websocket.log
redirect_stderr=true

Now update Supervisor with: sudo supervisorctl reread command. And start using those changes with: sudo supervisorctl update command

We now have a process called “websocket” which we will tell Supervisord to start out and monitor.

Let’s do that:

$ sudo supervisorctl
> reread # Tell supervisord to check for new items in /etc/supervisor/conf.d/
> add websocket       # Add this process to Supervisord
> start websocket     # May say "already started"

Now the “websocket” process is on and being monitored. If our queue listener fails, Supervisord will restart the php artisan websocket:init process.

Taggs:
Write a comment