setAdapter(new RedisAdapter(new MySQLAdapter($register), $register)); $consoleDB->setNamespace('app_console'); // Main DB $consoleDB->setMocks(Config::getParam('collections', [])); return $consoleDB; } function notifyDeleteExecutionLogs() { Resque::enqueue(DELETE_QUEUE_NAME, DELETE_CLASS_NAME, [ 'type' => DELETE_TYPE_EXECUTION_LOGS, 'document' => new Document([ '$collection' => Database::SYSTEM_COLLECTION_EXECUTIONS ]) ]); } function notifyDeleteAbuseLogs(int $interval) { Resque::enqueue(DELETE_QUEUE_NAME, DELETE_CLASS_NAME, [ 'type' => DELETE_TYPE_ABUSE, 'timestamp' => time() - $interval ]); } function notifyDeleteAuditLogs(int $interval) { Resque::enqueue(DELETE_QUEUE_NAME, DELETE_CLASS_NAME, [ 'type' => DELETE_TYPE_AUDIT, 'timestamp' => time() - $interval ]); } $cli ->task('maintenance') ->desc('Schedules maintenance tasks and publishes them to resque') ->action(function () { // # of days in seconds (1 day = 86400s) $interval = App::getEnv('_APP_MAINTENANCE_INTERVAL', '') + 0; //Convert Seconds to microseconds $intervalMicroseconds = $interval * 1000000; $consoleDB = getConsoleDB(); Console::loop(function() use ($consoleDB, $interval){ Console::info("[ MAINTENANCE TASK ] Notifying deletes workers every {$interval} seconds"); notifyDeleteExecutionLogs(); notifyDeleteAbuseLogs($interval); notifyDeleteAuditLogs($interval); }, $intervalMicroseconds); });