-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2551d4b
commit 63093f1
Showing
2 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace RalphJSmit\LaravelHorizonCron\Supervisor\Console; | ||
|
||
use Illuminate\Console\Command; | ||
|
||
class RestartHorizon extends Command | ||
{ | ||
protected $signature = 'supervisor:check'; | ||
|
||
protected $description = 'Checks if Horizon is running, starts the queue if needed.'; | ||
|
||
/** | ||
* The command the actually performs the logic | ||
*/ | ||
public function handle() | ||
{ | ||
$res = shell_exec("php artisan horizon:status"); | ||
|
||
if($res !== "Horizon is running.\n") { | ||
echo "horizon is not running, starting it\n"; | ||
$fp = popen("php artisan horizon", "r"); | ||
while (!feof($fp)) { | ||
$buffer = fgets($fp, 4096); | ||
echo $buffer; | ||
} | ||
echo "horizon was terminated\n"; | ||
pclose($fp); | ||
} else { | ||
echo "horizon is running\n"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters