|
75 | 75 | minRefreshDurationInSeconds: 60,
|
76 | 76 | server: $server,
|
77 | 77 | packageVersion: $packageVersion,
|
78 |
| - onAuthenticationSuccess: static fn (IngestDetails $ingestDetails, float $duration) => $info('Authentication successful ['.round($duration, 3).'s]'), |
79 |
| - onAuthenticationError: static fn (Throwable $e, float $duration) => $info('Authentication failed ['.round($duration, 3).'s]: '.$e->getMessage()), |
| 78 | + onAuthenticationSuccess: static fn (IngestDetails $ingestDetails, float $duration) => $info('Authentication successful against ['.$baseUrl.'] ['.round($duration, 3).'s]'), |
| 79 | + onAuthenticationError: static fn (Throwable $e, float $duration) => $info('Authentication failed against ['.$baseUrl.'] ['.round($duration, 3).'s]: '.$e->getMessage()), |
80 | 80 | );
|
81 | 81 |
|
82 | 82 | $ingest = (new IngestFactory)(
|
|
95 | 95 |
|
96 | 96 | $server = (new ServerFactory)(
|
97 | 97 | listenOn: $listenOn,
|
98 |
| - onServerStarted: static fn () => $info("Nightwatch agent initiated: Listening on [{$listenOn}]."), |
| 98 | + onServerStarted: static fn () => $info("Nightwatch agent initiated: Listening on [{$listenOn}]"), |
99 | 99 | onServerError: static fn (Throwable $e) => $error("Server error: {$e->getMessage()}"),
|
100 | 100 | onConnectionError: static fn (Throwable $e) => $error("Connection error: {$e->getMessage()}"),
|
101 | 101 | onPayloadReceived: $ingest->write(...),
|
102 | 102 | );
|
103 | 103 |
|
| 104 | +$signature = new Signature( |
| 105 | + path: $basePath.'/signature.txt', |
| 106 | + verificationIntervalInSeconds: 5, |
| 107 | + onChange: static function (string $before, string $after) use ($info) { |
| 108 | + $info("Restarting the agent as the signature has changed [{$before}] [{$after}]"); |
| 109 | + |
| 110 | + Loop::stop(); |
| 111 | + }, |
| 112 | +); |
| 113 | + |
104 | 114 | /*
|
105 | 115 | * Get things rolling...
|
106 | 116 | */
|
107 | 117 |
|
| 118 | +$signature->capture(); |
| 119 | + |
108 | 120 | $server->start();
|
109 | 121 |
|
110 | 122 | $ingestDetails->hydrate();
|
|
0 commit comments