change-status-poweroff #79
|
|
@ -1,5 +1,9 @@
|
|||
# Changelog
|
||||
|
||||
## [1.2.10] - 2026-03-25
|
||||
### Added
|
||||
Modificado StatusController para que al recibir un webhook de Poweroff o reboot actualice el estado de las trazas en progreso y las ponga como finalizadas.
|
||||
|
||||
## [1.2.9] - 2026-03-25
|
||||
### Added
|
||||
- Nuevo webhook `START_SCRIPT` en StatusController que permite crear automáticamente una entidad Trace y poner el equipo local en estado `BUSY` cuando un cliente inicia sus propios scripts de forma autónoma (ej: menús locales de ogLive).
|
||||
|
|
|
|||
|
|
@ -96,6 +96,28 @@ class StatusController extends AbstractController
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['nfn']) && in_array($data['nfn'], ['REBOOT', 'POWEROFF'], true)) {
|
||||
$clientIp = $data['iph'] ?? $request->getClientIp();
|
||||
$client = $this->entityManager->getRepository(Client::class)->findOneBy(['ip' => $clientIp]);
|
||||
if ($client) {
|
||||
$traces = $this->entityManager->getRepository(Trace::class)->findBy(['client' => $client, 'status' => TraceStatus::IN_PROGRESS]);
|
||||
foreach ($traces as $trace) {
|
||||
$trace->setStatus(TraceStatus::SUCCESS);
|
||||
$trace->setFinishedAt(new \DateTime());
|
||||
$this->entityManager->persist($trace);
|
||||
}
|
||||
|
||||
if ($client->getStatus() === ClientStatus::BUSY) {
|
||||
$newStatus = ($data['nfn'] === 'REBOOT') ? ClientStatus::INITIALIZING : ClientStatus::TURNING_OFF;
|
||||
$client->setStatus($newStatus);
|
||||
$this->entityManager->persist($client);
|
||||
}
|
||||
|
||||
$this->entityManager->flush();
|
||||
$this->logger->info('Reboot/Poweroff webhook received. Automatically resolved in-progress traces.', ['num_traces' => count($traces), 'nfn' => $data['nfn']]);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['progress'])){
|
||||
$trace = $this->entityManager->getRepository(Trace::class)->findOneBy(['jobId' => $data['job_id']]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue