Laravel

Setting Up Supervisor With Laravel Pulse On Ubuntu

Harry 2 min read
Laravel Pulse Dashboard
Table of Contents

Laravel Pulse has been released into the wild and if you are keen to try it out, this tutorial will take you through setting up Pulse and installing Supervisor to make full use of Server Recorders.

Installing Laravel Pulse

Go ahead and follow the installation guide provided by the Laravel documentation. This should get you through most of the requirements to install Pulse.

Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.

Installing Supervisor

Once you're at this stage, you'll notice that your dashboard isn't reporting your server specs. So let's get this sorted.

If you run the following command, you'll then begin to see server data in your Pulse dashboard. The issue is that you must keep this process running to continue receiving live statistics.

php artisan pulse:check

To solve this, we'll install Supervisor, a process manager for running commands in the background.

SSH into your ubuntu server with a user that has permission to access sudo (or root).

sudo apt update && sudo apt install supervisor

Then afterwards we're going to create a configuration file to spawn our process. Feel free to replace vim with your preferred editor.

vim /etc/supervisor/conf.d/pulse.conf

You can mostly take the below configuration, but replace www-data with the user your web server runs under. (do not use root)

Also, /your-laravel-project-path/ will depend on where your project is located, so make sure that reflects your environment.

[program:laravel_pulse]
process_name=%(program_name)s
command=php /your-laravel-project-path/artisan pulse:check
autostart=true
autorestart=true
user=www-data
redirect_stderr=true
stdout_logfile=/your-laravel-project-path/shared/pulse.log
stopwaitsecs=3600

Once you are satisfied with the above, we need to tell supervisor about it.

Instruct supervisor to scan for new config files with the below, then we need to apply it with update.

supervisorctl reread
supervisorctl update

Finally, instruct supervisor to start the process.

supervisorctl start laravel_pulse

Then there you have it. You can additionally call supervisorctl status to confirm everything is running. But you can also check out your Pulse dashboard to start seeing your server statistics updating in real time.

Should your server reboot or the process die for whatever reason. Supervisor will go ahead and respawn it so it should continue running unless there's a reason it cannot run.

Share
Comments
More from Harrk Blog

Harrk Blog

Programming nonsense, tutorials, and random musings about games and technology.

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to Harrk Blog.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.