Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

horizon:restart command fails #1388

Closed
sebastiaanluca opened this issue Feb 15, 2024 · 4 comments
Closed

horizon:restart command fails #1388

sebastiaanluca opened this issue Feb 15, 2024 · 4 comments
Labels

Comments

@sebastiaanluca
Copy link

sebastiaanluca commented Feb 15, 2024

Horizon Version

5.23.0

Laravel Version

10.44.0

PHP Version

8.2.15

Redis Driver

PhpRedis

Redis Version

2.2.2

Database Driver & Version

mysql Ver 8.1.0 for macos14.0 on arm64 (Homebrew)

Description

It seems #1387 broke the output of the php artisan horizon:restart command (and maybe others).

We restart Horizon every so often via a scheduled job and after the update from yesterday we've been getting these in production. So it's interpreting the status message as output instead of the status code?

Confirmed it still works on v5.22.1.

The exceptions:

RuntimeException
Horizon returned an unknown status "   INFO  Horizon is running.  " and could not be restarted.

    protected $description = "Restart Horizon if it's currently running";
    public function handle(): int
    {
        if (! $this->isSupportedStatus($status = $this->getHorizonStatus())) {
            throw new RuntimeException(sprintf('Horizon returned an unknown status "%s" and could not be restarted.', $status));
        }
        if ($status !== 'Horizon is running.') {
            return static::SUCCESS;
        }
App\Exceptions\ScheduledCommandException
The scheduled command `'/usr/bin/php8.2' 'artisan' horizon:restart` failed to complete successfully. 
In RestartHorizon.php line 29:
                                                                               
  Horizon returned an unknown status "   INFO  Horizon is running.  " and cou  
  ld not be restarted.       

    {
        $output = file_exists($event->output)
            ? file_get_contents($event->output)
            : 'No output found.';
        return new self(sprintf(
            'The scheduled command `%s` failed to complete successfully. %s',
            $event->command ?? $event->description,
            $output,
        ));
    }

Steps To Reproduce

In one terminal shell:

php artisan horizon

In another:

php artisan horizon:restart
@driesvints
Copy link
Member

Thanks @sebastiaanluca. Assigning @nunomaduro here.

@driesvints driesvints added the bug label Feb 15, 2024
@nunomaduro
Copy link
Member

The command horizon:restart is not something we provide with Horizon. So, I must assume is something you have coded in your side. You need to adapt your command to the new output provided by php artisan horizon:status.

@sebastiaanluca
Copy link
Author

The command horizon:restart is not something we provide with Horizon. So, I must assume is something you have coded in your side. You need to adapt your command to the new output provided by php artisan horizon:status.

After some thorough research (finding the command in our own codebase), I must conclude that's exactly the case 😆 Sorry all, didn't pay much attention here. The exceptions linked directly to Horizon without any trace of our command, so skipped that check.

Do agree with #1387 (comment) here a bit, it could be considered a breaking change.

@driesvints
Copy link
Member

Hey @sebastiaanluca, please see my reply here: #1387 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants