Skip to content

Commit

Permalink
Added onOneServer support and updated StyleCI config. (#103)
Browse files Browse the repository at this point in the history
* Added onOneServer support
  • Loading branch information
jayjfletcher authored and roshangautam committed Jul 4, 2018
1 parent b068ed1 commit 18fb3c4
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 4 deletions.
4 changes: 1 addition & 3 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
preset: laravel

linting: true
preset: laravel
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AlterTasksTableAddRunOnOneServerSupport extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table(config('totem.table_prefix').'tasks', function (Blueprint $table) {
$table->boolean('run_on_one_server')->default(false);
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table(config('totem.table_prefix').'tasks', function (Blueprint $table) {
$table->dropColumn('run_on_one_server');
});
}
}
8 changes: 8 additions & 0 deletions resources/views/tasks/form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@
<ul class="uk-list uk-padding-remove">
<li class="uk-text-meta">Decide whether multiple instances of same task should overlap each other or not.</li>
<li class="uk-text-meta">Decide whether the task should be executed while the app is in maintenance mode.</li>
<li class="uk-text-meta">Decide whether the task should be executed on a single server.</li>
</ul>
</div>
<div class="uk-width-1-1@s uk-width-2-3@m uk-form-controls-text">
Expand All @@ -214,6 +215,13 @@
Run in maintenance mode
</label>
</div>
<div class="uk-margin">
<label class="uk-margin">
<input type="hidden" name="run_on_one_server" id="run_on_one_server" value="0" {{old('run_on_one_server', $task->run_on_one_server) ? '' : 'checked'}}>
<input type="checkbox" name="run_on_one_server" id="run_on_one_server" value="1" {{old('run_on_one_server', $task->run_on_one_server) ? 'checked' : ''}}>
Run on a single server
</label>
</div>
</div>
</div>
<hr class="uk-divider-icon">
Expand Down
5 changes: 5 additions & 0 deletions resources/views/tasks/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@
<span class="uk-float-left">Runs in maintenance mode</span>
</li>
@endif
@if($task->run_on_one_server)
<li>
<span class="uk-float-left">Runs on a single server</span>
</li>
@endif
</ul>
@stop
@section('main-panel-footer')
Expand Down
3 changes: 2 additions & 1 deletion src/Console/Commands/ListSchedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ public function handle()
'timezone' => $event->timezone ?: config('app.timezone'),
'overlaps' => $event->withoutOverlapping ? 'No' : 'Yes',
'maintenance' => $event->evenInMaintenanceMode ? 'Yes' : 'No',
'one_server' => $event->onOneServer ? 'Yes' : 'No',
];
});

$this->table(
['Description', 'Command', 'Schedule', 'Upcoming', 'Timezone', 'Overlaps?', 'In Maintenance?'],
['Description', 'Command', 'Schedule', 'Upcoming', 'Timezone', 'Overlaps?', 'In Maintenance?', 'One Server?'],
$events
);
} else {
Expand Down
3 changes: 3 additions & 0 deletions src/Providers/ConsoleServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public function schedule(Schedule $schedule)
if ($task->run_in_maintenance) {
$event->evenInMaintenanceMode();
}
if ($task->run_on_one_server && in_array(config('cache.default'), ['memcached', 'redis'])) {
$event->onOneServer();
}
});
}
}
1 change: 1 addition & 0 deletions src/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Task extends TotemModel
'notification_slack_webhook',
'auto_cleanup_type',
'auto_cleanup_num',
'run_on_one_server',
];

/**
Expand Down

0 comments on commit 18fb3c4

Please sign in to comment.