FilamentF
Filament14mo ago
Matthew

Action is always loading when running a laravel process

The main goal is to run a laravel process that starts a local game server. However, after running the process (and while its running) the action is always "loading" as shown in the picture. I understand why this is happening, but I was wondering if there was a way to get around it? After clicking launch, it should start the process and stop loading.
Here is my code so far
<?php

namespace App\Filament\Pages;

class extends Page
{
    protected function getHeaderActions(): array
    {
        return [
            Action::make('launchAction')
                ->color('success')
                ->label('Launch Server')
                ->after(function () {
                    // ...
                    try {
                        $process = Process::fromShellCommandline($command, $mcDir);
                        $process->setTimeout(null);

                        // Async process
                        $process->start();

                    } catch (Exception $e) {
                        Log::error('Failed to launch server: ' . $e->getMessage());
                        throw $e;
                    }
                }),
        ];
    }
}
image.png
Solution
I would look into jobs and listeners and how you can leverage them with reverb.
Was this page helpful?