Un-butcher task system.

This commit is contained in:
Dane Everitt 2017-04-15 13:52:43 -04:00
parent 0fe9a4566e
commit 7f1a97184b
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
12 changed files with 154 additions and 77 deletions

View file

@ -25,7 +25,7 @@
namespace Pterodactyl\Console\Commands;
use Carbon;
use Pterodactyl\Models;
use Pterodactyl\Models\Task;
use Illuminate\Console\Command;
use Pterodactyl\Jobs\SendScheduledTask;
use Illuminate\Foundation\Bus\DispatchesJobs;
@ -65,14 +65,14 @@ class RunTasks extends Command
*/
public function handle()
{
$tasks = Models\Task::where('queued', 0)->where('active', 1)->where('next_run', '<=', Carbon::now()->toAtomString())->get();
$tasks = Task::where('queued', false)->where('active', true)->where('next_run', '<=', Carbon::now()->toAtomString())->get();
$this->info(sprintf('Preparing to queue %d tasks.', count($tasks)));
$bar = $this->output->createProgressBar(count($tasks));
foreach ($tasks as &$task) {
$bar->advance();
$this->dispatch((new SendScheduledTask(Models\Server::findOrFail($task->server), $task))->onQueue(config('pterodactyl.queues.low')));
$this->dispatch((new SendScheduledTask($task))->onQueue(config('pterodactyl.queues.low')));
}
$bar->finish();