Skip to content

Commit a2134eb

Browse files
committed
Variable timings
1 parent 22e4420 commit a2134eb

File tree

5 files changed

+28
-4
lines changed

5 files changed

+28
-4
lines changed

config/tmi-cluster.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,29 @@
9393
'channels' => []
9494
],
9595

96+
/*
97+
|--------------------------------------------------------------------------
98+
| TMI Supervisor & Process Configuration
99+
|--------------------------------------------------------------------------
100+
|
101+
| Here you may specify the timings, we recommend to leave them on default
102+
| and not to change them. You can delete this section if you always want
103+
| to have the package defaults.
104+
|
105+
| All timings are specified in seconds.
106+
|
107+
*/
108+
109+
'supervisor' => [
110+
'stale' => 300,
111+
],
112+
113+
'process' => [
114+
'stale' => 90,
115+
'timeout' => 60,
116+
'periodic_timer' => 2,
117+
],
118+
96119
/*
97120
|--------------------------------------------------------------------------
98121
| TMI Cluster Auto Scaling Thresholds

src/Models/Supervisor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Supervisor extends Model
3636

3737
public function getIsStaleAttribute(): bool
3838
{
39-
return $this->last_ping_at->diffInSeconds() >= 300;
39+
return $this->last_ping_at->diffInSeconds() >= config('tmi-cluster.supervisor.stale', 300);
4040
}
4141

4242
public function processes(): HasMany

src/Models/SupervisorProcess.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function supervisor(): BelongsTo
4646
public function getIsStaleAttribute(): bool
4747
{
4848
// we require at least 60 seconds for our restart cooldown
49-
return $this->last_ping_at->diffInSeconds() >= 90;
49+
return $this->last_ping_at->diffInSeconds() >= config('tmi-cluster.process.stale', 90);
5050
}
5151

5252
public function getMemoryUsageAttribute(): string

src/Process/ProcessOptions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ public function getSupervisor(): string
3030

3131
public function getTimeout(): int
3232
{
33-
return $this->options['timeout'] ?? 60;
33+
return $this->options['timeout'] ?? config('tmi-cluster.process.timeout', 60);
3434
}
3535
}

src/TmiClusterClient.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ public static function make(ClusterClientOptions $options, Closure $output): sel
8888

8989
private function registerPeriodicTimer(): void
9090
{
91-
$this->client->getLoop()->addPeriodicTimer(2, function () {
91+
$interval = config('tmi-cluster.process.periodic_timer', 2);
92+
$this->client->getLoop()->addPeriodicTimer($interval, function () {
9293
$this->processPendingSignals();
9394

9495
$this->processPendingCommands();

0 commit comments

Comments
 (0)