commit21
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/** Technical observation only; contains no company data or business authority. */
|
||||
class ReplenishmentHeartbeat
|
||||
{
|
||||
public function fingerprint(): string
|
||||
{
|
||||
$connection = DB::connection();
|
||||
|
||||
return hash('sha256', json_encode([base_path(), config('work_context.composition'), $connection->getDriverName(),
|
||||
$connection->getConfig('host'), $connection->getConfig('port'), $connection->getDatabaseName()], JSON_THROW_ON_ERROR));
|
||||
}
|
||||
|
||||
public function record(string $started, int $exitCode): void
|
||||
{
|
||||
app(Filesystem::class)->replace(storage_path('framework/replenishment-command-status.json'), json_encode([
|
||||
'started_at' => $started,
|
||||
'finished_at' => now()->toIso8601String(),
|
||||
'scope' => 'SGC replenishment command',
|
||||
'result' => $exitCode === 0 ? 'passed' : 'retry_pending',
|
||||
'exit_code' => $exitCode,
|
||||
'installation' => $this->fingerprint(),
|
||||
], JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user