Skip to content

Commit eb0ba96

Browse files
authored
Merge pull request #211 from open-runtimes/refactor-delete-stats
refactor: delete stats
2 parents 53fc97f + ed3ac43 commit eb0ba96

File tree

6 files changed

+4
-202
lines changed

6 files changed

+4
-202
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ docker compose down
139139
| GET |`/v1/runtimes/{runtimeId}`| Get a runtime by its ID | [JSON](#v1runtimesruntimeid) |
140140
| DELETE |`/v1/runtimes/{runtimeId}`| Delete a runtime | [JSON](#v1runtimesruntimeid) |
141141
| POST |`/v1/runtimes/{runtimeId}/executions`| Create an execution | [JSON](#v1runtimesruntimeidexecutions) |
142-
| GET |`/v1/health`| Get health status of host machine and runtimes | X |
142+
| GET |`/v1/health`| Get health status | X |
143143

144144
#### /v1/runtimes/{runtimeId}/logs
145145
| Param | Type | Description | Required | Default |

app/controllers.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -308,16 +308,10 @@ function (
308308
);
309309

310310
Http::get('/v1/health')
311-
->desc("Get health status of host machine and runtimes.")
312-
->inject('runner')
311+
->desc("Get health status")
313312
->inject('response')
314-
->action(function (Runner $runner, Response $response) {
315-
$stats = $runner->getStats();
316-
$output = [
317-
'usage' => $stats->getHostUsage(),
318-
'runtimes' => $stats->getContainerUsage(),
319-
];
320-
$response->setStatusCode(Response::STATUS_CODE_OK)->json($output);
313+
->action(function (Response $response) {
314+
$response->setStatusCode(Response::STATUS_CODE_OK)->text("OK");
321315
});
322316

323317
Http::init()

src/Executor/Runner/Adapter.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace OpenRuntimes\Executor\Runner;
44

5-
use OpenRuntimes\Executor\Stats;
65
use Utopia\Http\Response;
76
use Utopia\Logger\Log;
87

@@ -115,6 +114,4 @@ abstract public function createExecution(
115114
abstract public function getRuntimes(): mixed;
116115

117116
abstract public function getRuntime(string $name): mixed;
118-
119-
abstract public function getStats(): Stats;
120117
}

src/Executor/Runner/Docker.php

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
use Appwrite\Runtimes\Runtimes as AppwriteRuntimes;
77
use OpenRuntimes\Executor\Exception;
88
use OpenRuntimes\Executor\Runner\Repository\Runtimes;
9-
use OpenRuntimes\Executor\Stats;
109
use OpenRuntimes\Executor\StorageFactory;
11-
use OpenRuntimes\Executor\Usage;
1210
use OpenRuntimes\Executor\Validator\TCP;
1311
use Swoole\Process;
1412
use Swoole\Timer;
@@ -26,8 +24,6 @@
2624

2725
class Docker extends Adapter
2826
{
29-
private Stats $stats;
30-
3127
/**
3228
* @param Orchestration $orchestration
3329
* @param Runtimes $runtimes
@@ -38,7 +34,6 @@ public function __construct(
3834
private readonly Runtimes $runtimes,
3935
private readonly NetworkManager $networkManager
4036
) {
41-
$this->stats = new Stats();
4237
$this->init();
4338
}
4439

@@ -132,25 +127,6 @@ private function init(): void
132127

133128
Console::success('Maintenance interval started.');
134129

135-
/**
136-
* Get usage stats every X seconds to update swoole table
137-
*/
138-
Console::info('Starting stats interval...');
139-
$getStats = function (): void {
140-
// Get usage stats
141-
$usage = new Usage($this->orchestration);
142-
$usage->run();
143-
$this->stats->updateStats($usage);
144-
};
145-
146-
// Load initial stats in blocking way
147-
$getStats();
148-
149-
// Setup infinite recursion in non-blocking way
150-
\go(fn () => Timer::after(1000, fn () => $getStats()));
151-
152-
Console::success('Stats interval started.');
153-
154130
Process::signal(SIGINT, fn () => $this->cleanUp());
155131
Process::signal(SIGQUIT, fn () => $this->cleanUp());
156132
Process::signal(SIGKILL, fn () => $this->cleanUp());
@@ -1236,9 +1212,4 @@ public function getRuntime(string $name): mixed
12361212

12371213
return $runtime->toArray();
12381214
}
1239-
1240-
public function getStats(): Stats
1241-
{
1242-
return $this->stats;
1243-
}
12441215
}

src/Executor/Stats.php

Lines changed: 0 additions & 79 deletions
This file was deleted.

src/Executor/Usage.php

Lines changed: 0 additions & 81 deletions
This file was deleted.

0 commit comments

Comments
 (0)