Skip to content

Commit 18fb3c4

Browse files
jayjfletcherroshangautam
authored andcommitted
Added onOneServer support and updated StyleCI config. (#103)
* Added onOneServer support
1 parent b068ed1 commit 18fb3c4

File tree

7 files changed

+52
-4
lines changed

7 files changed

+52
-4
lines changed

.styleci.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
preset: laravel
2-
3-
linting: true
1+
preset: laravel
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Schema;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Database\Migrations\Migration;
6+
7+
class AlterTasksTableAddRunOnOneServerSupport extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::table(config('totem.table_prefix').'tasks', function (Blueprint $table) {
17+
$table->boolean('run_on_one_server')->default(false);
18+
});
19+
}
20+
21+
/**
22+
* Reverse the migrations.
23+
*
24+
* @return void
25+
*/
26+
public function down()
27+
{
28+
Schema::table(config('totem.table_prefix').'tasks', function (Blueprint $table) {
29+
$table->dropColumn('run_on_one_server');
30+
});
31+
}
32+
}

resources/views/tasks/form.blade.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@
198198
<ul class="uk-list uk-padding-remove">
199199
<li class="uk-text-meta">Decide whether multiple instances of same task should overlap each other or not.</li>
200200
<li class="uk-text-meta">Decide whether the task should be executed while the app is in maintenance mode.</li>
201+
<li class="uk-text-meta">Decide whether the task should be executed on a single server.</li>
201202
</ul>
202203
</div>
203204
<div class="uk-width-1-1@s uk-width-2-3@m uk-form-controls-text">
@@ -214,6 +215,13 @@
214215
Run in maintenance mode
215216
</label>
216217
</div>
218+
<div class="uk-margin">
219+
<label class="uk-margin">
220+
<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'}}>
221+
<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' : ''}}>
222+
Run on a single server
223+
</label>
224+
</div>
217225
</div>
218226
</div>
219227
<hr class="uk-divider-icon">

resources/views/tasks/view.blade.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@
7171
<span class="uk-float-left">Runs in maintenance mode</span>
7272
</li>
7373
@endif
74+
@if($task->run_on_one_server)
75+
<li>
76+
<span class="uk-float-left">Runs on a single server</span>
77+
</li>
78+
@endif
7479
</ul>
7580
@stop
7681
@section('main-panel-footer')

src/Console/Commands/ListSchedule.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,12 @@ public function handle()
5858
'timezone' => $event->timezone ?: config('app.timezone'),
5959
'overlaps' => $event->withoutOverlapping ? 'No' : 'Yes',
6060
'maintenance' => $event->evenInMaintenanceMode ? 'Yes' : 'No',
61+
'one_server' => $event->onOneServer ? 'Yes' : 'No',
6162
];
6263
});
6364

6465
$this->table(
65-
['Description', 'Command', 'Schedule', 'Upcoming', 'Timezone', 'Overlaps?', 'In Maintenance?'],
66+
['Description', 'Command', 'Schedule', 'Upcoming', 'Timezone', 'Overlaps?', 'In Maintenance?', 'One Server?'],
6667
$events
6768
);
6869
} else {

src/Providers/ConsoleServiceProvider.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ public function schedule(Schedule $schedule)
5050
if ($task->run_in_maintenance) {
5151
$event->evenInMaintenanceMode();
5252
}
53+
if ($task->run_on_one_server && in_array(config('cache.default'), ['memcached', 'redis'])) {
54+
$event->onOneServer();
55+
}
5356
});
5457
}
5558
}

src/Task.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class Task extends TotemModel
3131
'notification_slack_webhook',
3232
'auto_cleanup_type',
3333
'auto_cleanup_num',
34+
'run_on_one_server',
3435
];
3536

3637
/**

0 commit comments

Comments
 (0)