Supervisor Fix: Invalid Username Error

Photo by Markus Spiske on Unsplash

Supervisor is a client/server system that allows its users to control a number of processes on UNIX-like operating systems. It is basically a linux based daemon that runs in the background. If you are running a laravel application for example on a live server with jobs that are to be run, we have to configure our laravel app so that supervisor know about background jobs.

After setting up supervisor, you may run into errors like the “Invalid Username Error”.

What causes this error?

Well, this error pops up if the username you specified to run the supervisor process is incorrect.

From the above, you’ll notice that the username is apache which should not be.

How to fix this issue

There are two solutions to this problem.

Why? The user is not a mandatory field in the Supervisor process config file, you can just comment the line with ; if you don't need a specific user to run the task.

For example in the laravel artisan command that I have above:
;user=apache

But this poses an issue for laravel users. Not defining a user may allow the system root to create log and cache files that are inaccessible to your Laravel application. This can result in a cascade of issues. It is highly recommend to set an appropriate user for your worker according to the application.

For me, this worked like a charm. I’ll recommend you use this second fix though, so as not to run into issues in your codebase.

Voila!
Issue Fixed!
Happy Coding!

A fullstack web developer and a techwriter when the need arises.