Question about deploying project with Supervisor

Hello,

I have a question about using Supervisor:

When I re-deploy my projects, will this automatically restart Supervisor?

I’m not sure if I need to do anything extra to make sure Supervisor pick up on the changes.

Thank you!
/chris

Hello @webify,

If there is a way to terminate the process running in Process Monitor, it will indeed be restarted. You can include a custom hook with the termination command and place it at the end of the deployment hooks.

Could you please provide more details about what you are trying to execute using Process Monitor?

@anish i use supervisor to spin up workers ( redis / php ) which send http requests to my api endpoint. All working. All good. My question is if i re-deploy with new code. Will the supervisor restart with the deployment?

Hello @webify,

The process managed by Supervisor will automatically restart if it is terminated or stopped.

You can add a custom deployment hook to stop or restart the process, which will subsequently trigger its restart under Supervisor.

Hi @anish

Thank you. I’ve tried implementing a deployment hook to restart Supervisor, but I’m encountering some issues and could use your guidance.

webify.works

I’ve added a deployment hook at the end of my deployment process called “Restarting Supervisor”. However, this new step keeps failing during deployment. Unfortunately, I only get an error message “Error” without any context.

Here’s the deployment hook I’m using:

#!/bin/bash
sudo systemctl restart supervisor

I’m not entirely sure if this is the correct approach. I’m relatively new to this, so any guidance would be greatly appreciated.

Hello @webify,

When resolving issues related to Supervisor processes, we typically need to restart or terminate the specific process being monitored rather than simply restarting Supervisor itself.

Are you utilizing Supervisor outside of Cleavr’s UI or relying on our built-in Process Monitor feature (Process Monitors - Cleavr docs)?

As an example, consider a Laravel Horizon setup. To ensure seamless integration with your application:

  1. Create a Process Monitor and specify php artisan horizon as the command.

  2. Configure a hook using the following script:

    sudo -u {{ username }} /usr/bin/php/php{{ phpVersion }} /home/{{ username }}/{{ site }}/current/artisan horizon:terminate

With this configuration, our Process Monitor will take care of terminating Horizon after each deployment, allowing you to restart it with the updated code.

Let me know if you have any further questions or concerns!

Hi @anish,
I have a similar use case where I run an Adonis.js API and need to restart a queue each time I re-deploy my project (GitHub - RomainLanz/adonis-bull-queue: Queue system based on BullMQ for AdonisJS). Currently, I handle this manually through Cleavr’s UI.

I attempted to automate this process by creating a deployment hook with the following command:

supervisorctl restart all

But got this error:

error: <class 'PermissionError'>, [Errno 13] Permission denied: file: /usr/lib/python3/dist-packages/supervisor/xmlrpc.py line: 560

It appears to be a permissions issue. When I SSH as the root user, the command works, but my supervisor command runs under the “cleavr” user. Am I missing something? I thought the deployment hooks also run under the “cleavr” user?

Thanks

Hello everyone,

To properly terminate the Adonis Bull Queue service, a few manual steps are necessary, as the Adonis Bull Service does not directly provide a way to terminate it. Here’s how to configure it effectively:

  1. SSH into the Server and Run the Following Command:
echo "{{ user }} ALL=NOPASSWD: /usr/bin/supervisorctl restart" | sudo tee /etc/sudoers.d/supervisor > /dev/null
  • Replace {{ user }} with the server user associated with your site. By default, this is cleavr .
  1. Configure a Deployment Hook:
    Go to the Deployment Hooks page and add a new hook with the following script:
sudo supervisorctl restart {{ processMonitorName }}
  • You can find the processMonitorName on the Process Monitors page. Make sure to replace spaces in the name with - .

This setup will ensure that your deployment hook can restart the Adonis Bull Queue service after a deployment.

Place the hook at the end of the deployment process.

1 Like

Hi @anish,

Thank you for your helpful guidance! I wanted to share some additional steps I needed to take to get this working properly, which might help others:

  1. Add the “*” asterisk after restart, so that any restart works:
echo "cleavr ALL=NOPASSWD: /usr/bin/supervisorctl restart *" | sudo tee /etc/sudoers.d/supervisor > /dev/null
  1. I had to fix the permissions on the sudoers file:
sudo chmod 0440 /etc/sudoers.d/supervisor
  1. For the deployment hook, I found that using the wildcard pattern works best since supervisor uses group names. My working hook looks like this:
sudo supervisorctl restart "{{ processMonitorName }}:*"

The key things I learned:

  • The process name in supervisorctl is case-sensitive and includes the group name
  • Using the wildcard pattern (":*") helps when you have multiple workers in a group

This setup now successfully restarts my queue workers after each deployment. Hope this helps others!