Skip to content

Commit f45e0f4

Browse files
committed
fix: make heartbeat non-configurable, always enabled
The heartbeat cannot be disabled or have its interval changed by end-users. This ensures all running instances are visible to the EntglDb team for monitoring ToS/license compliance. Changes: - HeartbeatWorker: removed HeartbeatEnabled and HeartbeatIntervalMinutes config knobs; interval is now a private constant (60 min) - HeartbeatWorker: heartbeat is sent for ALL instances regardless of whether a license file is loaded (AGPL users are also monitored) - Policy comment added: if a valid license is present, missed heartbeats do NOT restrict server functionality - appsettings.json: removed HeartbeatEnabled and HeartbeatIntervalMinutes keys - Dockerfile: removed LICENSE__HEARTBEATENABLED and LICENSE__HEARTBEATINTERVALMINUTES ENV vars
1 parent 1a418cc commit f45e0f4

3 files changed

Lines changed: 8 additions & 22 deletions

File tree

Dockerfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ ENV LICENSE__SOURCEURL=https://github.com/EntglDb/BLite.Server
6767
ENV LICENSE__HUBURL=https://licensehub.blitedb.com
6868
# Path to a license file on disk (leave empty to use Hub-based validation)
6969
ENV LICENSE__FILEPATH=
70-
# Whether to send periodic heartbeat pings to the License Hub
71-
ENV LICENSE__HEARTBEATENABLED=true
72-
ENV LICENSE__HEARTBEATINTERVALMINUTES=60
7370
# PEM-encoded public key used to verify offline license files (leave empty for Hub validation)
7471
ENV LICENSE__PUBLICKEYPEM=
7572

src/BLite.Server/License/HeartbeatWorker.cs

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,19 @@ namespace BLite.Server.License;
88

99
public sealed class HeartbeatWorker : BackgroundService
1010
{
11+
// Heartbeat is always enabled and cannot be disabled by end-users.
12+
// This allows the EntglDb team to monitor active deployments and detect
13+
// potential license/ToS violations.
14+
// Policy: if a valid license is present, missed heartbeats do NOT cause
15+
// any restriction on server functionality — the heartbeat is telemetry only.
16+
private static readonly TimeSpan Interval = TimeSpan.FromMinutes(60);
17+
1118
private readonly ILogger<HeartbeatWorker> _log;
1219
private readonly LicenseManager _license;
1320
private readonly InstanceIdProvider _instance;
1421
private readonly IHttpClientFactory _httpFactory;
1522
private readonly string _hubUrl;
1623
private readonly string _licenseFilePath;
17-
private readonly bool _enabled;
18-
private readonly TimeSpan _interval;
1924
private readonly DateTime _startedAt = DateTime.UtcNow;
2025

2126
public HeartbeatWorker(
@@ -31,37 +36,23 @@ public HeartbeatWorker(
3136
_httpFactory = httpFactory;
3237
_hubUrl = cfg.GetValue<string>("License:HubUrl") ?? "https://licensehub.blitedb.com";
3338
_licenseFilePath = cfg.GetValue<string>("License:FilePath") ?? string.Empty;
34-
_enabled = cfg.GetValue<bool?>("License:HeartbeatEnabled") ?? true;
35-
var minutes = cfg.GetValue<int?>("License:HeartbeatIntervalMinutes") ?? 60;
36-
_interval = TimeSpan.FromMinutes(Math.Max(1, minutes));
3739
}
3840

3941
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
4042
{
41-
if (!_enabled)
42-
{
43-
_log.LogInformation("Heartbeat disabled via configuration.");
44-
return;
45-
}
46-
4743
// Stagger start time so many instances don't all fire simultaneously
4844
var jitter = TimeSpan.FromSeconds(Random.Shared.Next(0, 120));
4945
await Task.Delay(jitter, stoppingToken);
5046

5147
while (!stoppingToken.IsCancellationRequested)
5248
{
5349
await SendHeartbeatAsync(stoppingToken);
54-
await Task.Delay(_interval, stoppingToken);
50+
await Task.Delay(Interval, stoppingToken);
5551
}
5652
}
5753

5854
private async Task SendHeartbeatAsync(CancellationToken ct)
5955
{
60-
if (_license.Current is null)
61-
{
62-
_log.LogDebug("No license loaded — skipping heartbeat.");
63-
return;
64-
}
6556

6657
try
6758
{

src/BLite.Server/appsettings.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
"SourceUrl": "https://github.com/EntglDb/BLite.Server",
2020
"HubUrl": "https://licensehub.blitedb.com",
2121
"FilePath": "",
22-
"HeartbeatEnabled": true,
23-
"HeartbeatIntervalMinutes": 60,
2422
"PublicKeyPem": ""
2523
},
2624
"Studio": {

0 commit comments

Comments
 (0)