php – Laravel loop notificatios cron and supervisor-ThrowExceptions

Exception or error:

Who can help, prompt? Faced an atypical problem: When creating a new discussion or create channel event for communication with users, push notification loops, every minute the last notification generated comes in, writes to the database, but it feels like it is crashing somewhere, I use pushes to start cron and supervisor.

In the cron file settings: * * * * * / usr / local / bin / php / var / www / frandme-api / artisan schedule: run >> /var/log/cron.log 2> & 1

In laravel worker settings (supervisor folder):

[program:laravel_worker]
process_name=%(program_name)s_%(process_num)02d
command=/usr/local/bin/php /var/www/frandme-api/artisan queue:work --daemon --queue=default
autostart=true
autorestart=true
user=www-data
numprocs=4
redirect_stderr=true
stdout_logfile=/var/log/supervisor/laravel_worker.log

I will add that I use docker on windows.

And in Console / Kernel in general, like this:

 protected function schedule(Schedule $schedule)
    {
        //
    }

    private function runCommandAs($command, $name)
    {
        $monitor_file_path = storage_path($name);
        $number = exec($command);
        file_put_contents($monitor_file_path, $number);
    }

    /**
     * @param $name
     *
     * @return bool
     */
    private function canRunning($name): bool
    {
        $run_command = false;
        $monitor_file_path = storage_path($name);

        if (file_exists($monitor_file_path)) {
            $pid = file_get_contents($monitor_file_path);
            $result = exec("ps -p $pid --no-heading | awk '{print $1}'");
            if ($result == '') {
                $run_command = true;
            }
        } else {
            $run_command = true;
        }

        return $run_command;
    }

The project was recently given to me and immediately ran into such a problem.

I will be grateful to everyone who responds!

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *