1
0
Fork 0
mirror of synced 2024-07-19 05:16:15 +12:00
appwrite/app/tasks/maintenance.php

39 lines
1.1 KiB
PHP
Raw Normal View History

2020-12-15 05:39:44 +13:00
<?php
global $cli;
2020-12-15 10:26:37 +13:00
require_once __DIR__.'/../init.php';
use Appwrite\Database\Database;
use Appwrite\Database\Document;
2020-12-15 05:39:44 +13:00
use Utopia\App;
use Utopia\CLI\Console;
2020-12-15 10:26:37 +13:00
2020-12-15 05:39:44 +13:00
$cli
->task('maintenance')
->desc('Schedules maintenance tasks and publishes them to resque')
->action(function () {
2020-12-15 10:26:37 +13:00
// Convert string to integer
$interval = App::getEnv('_APP_MAINTENANCE_INTERVAL', '') + 0;
//Convert Seconds to microseconds
$interval = $interval * 1000000;
Console::loop(function() {
$projects = $consoleDB->getCollection([
'filters' => [
'$collection='.Database::SYSTEM_COLLECTION_PROJECTS,
],
]);
var_dump("*************** MAINTENANCE WORKER *****************");
print_r($projects);
Resque::enqueue('v1-deletes', 'DeletesV1', [
'document' => new Document([
'$collection' => Database::SYSTEM_COLLECTION_EXECUTIONS,
'projectIds' => $this->projects
]),
]);
}, $interval);
2020-12-15 05:39:44 +13:00
});