dinobudic's avatar

Horizon: supervisors keep respawning

Hello everybody, recently I've started using horizon on one older project that is still on version 5.8. I have issue with horizon supervisors that keep respawning each time with new pid. Seems to me that's not normal..

I have two supervirors configured: default and api-messages

Take a look at this when I run horizon:supervisors

+-----------------------------------+-------+---------+-------------------+-----------+
| Name                              | PID   | Status  | Workers           | Balancing |
+-----------------------------------+-------+---------+-------------------+-----------+
| xxxx:default | 37735 | running | redis:default (5) | auto      |
+-----------------------------------+-------+---------+-------------------+-----------+
+-----------------------------------+-------+---------+-------------------+-----------+
| Name                              | PID   | Status  | Workers           | Balancing |
+-----------------------------------+-------+---------+-------------------+-----------+
| vxxxx:default | 37890 | running | redis:default (5) | auto      |
+-----------------------------------+-------+---------+-------------------+-----------+
+----------------------------------------+-------+---------+------------------------+-----------+
| Name                                   | PID   | Status  | Workers                | Balancing |
+----------------------------------------+-------+---------+------------------------+-----------+
| xxxx:api-messages | 37904 | running | redis:api-messages (5) | auto      |
+----------------------------------------+-------+---------+------------------------+-----------+

Checked logs and there's nothing written. Test jobs are processed when I trigger them but I did not try to run actual jobs yet as they are heavy.

Am I off the track here, is that normal?

0 likes
1 reply
LaryAI's avatar
Level 58

The issue you're experiencing with Laravel Horizon, where supervisors keep respawning with new PIDs, is not typical behavior. This can happen due to several reasons, such as configuration issues, process management problems, or server resource constraints. Here are some steps you can take to troubleshoot and potentially resolve the issue:

  1. Check Supervisor Configuration: Ensure that your Horizon configuration file (config/horizon.php) is set up correctly. Pay special attention to the environments section to ensure that the supervisor settings are appropriate for your environment.

  2. Review Process Management: If you're using a process manager like Supervisor (not to be confused with Horizon's supervisors), ensure that it's configured correctly. A misconfiguration can cause processes to restart unexpectedly.

    Example Supervisor configuration for Horizon:

    [program:horizon]
    process_name=%(program_name)s
    command=php /path-to-your-project/artisan horizon
    autostart=true
    autorestart=true
    user=your-username
    redirect_stderr=true
    stdout_logfile=/path-to-your-project/storage/logs/horizon.log
    
  3. Check System Resources: Ensure that your server has enough resources (CPU, memory) to handle the processes. If the server is under heavy load, it might kill processes, causing them to respawn.

  4. Inspect Logs: Although you mentioned that logs don't show anything, double-check both Laravel logs (storage/logs/laravel.log) and system logs for any errors or warnings that might provide clues.

  5. Update Dependencies: Since you're using Laravel 5.8, ensure that all your dependencies, including Horizon, are up to date. There might be bug fixes in newer versions that address this issue.

  6. Check for Zombie Processes: Sometimes, zombie processes can cause issues with process management. Use a command like ps aux | grep horizon to check for any orphaned or zombie processes and kill them if necessary.

  7. Consider Upgrading: If possible, consider upgrading your Laravel application to a more recent version. Laravel 5.8 is quite old, and newer versions of Laravel and Horizon might have improvements and bug fixes that resolve this issue.

If none of these steps resolve the issue, consider reaching out to the community with detailed information about your setup, including your Horizon configuration and any relevant logs. This can help others provide more targeted assistance.

Please or to participate in this conversation.