<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;

final class WorkerHeartbeatCommand extends AbstractCommand
{
    public function name(): string { return 'worker:heartbeat'; }
    public function description(): string { return 'PPphp Worker Heartbeat'; }

    public function handle(array $arguments = []): int
    {
        $this->title('PPphp Worker Heartbeat');
        $manager = \PpPhp\Core\Platform\Event\Worker\Monitoring\WorkerHeartbeatManager::instance(\PpPhp\Core\Platform\Console\ConsolePath::basePath()); $manager->record('worker_console_heartbeat', 'running', 1, 0, 'console.heartbeat'); $summary = $manager->summary(); $stats = $summary['statistics']; $this->line('Workers: ' . $stats['workers']); $this->line('Running: ' . $stats['running']); $this->line('Persisted: ' . ($summary['persisted'] ? 'YES' : 'NO')); $this->line('Status: OK');
        return 0;
    }
}
