mirror of
https://git.sr.ht/~emerson/reflectionircd
synced 2025-04-13 09:59:52 +00:00
make lag and sync warning time configurable
This commit is contained in:
parent
c9e6d6cbe5
commit
b1677bb6ad
3 changed files with 6 additions and 2 deletions
|
@ -17,6 +17,8 @@ Copy `config.example.json` to `config.json`, and edit the values:
|
|||
* `port` is the listening port of the server
|
||||
* `certFile` and `keyFile` are the SSL cert and key for Reflection to use
|
||||
* `lazyLoadLimit` is the limit for "lazy load" mode. In lazy load mode, only room members with PL > 0 are shown right away, everyone else is joined once they send an event to the room. This prevents clients crashing or lagging on large rooms.
|
||||
* `syncTimeout` is the number of milliseconds to ask the homeserver to hold the sync open. `15000` seems to be the de-facto number.
|
||||
* `lagWarningLimit` is the number of milliseconds that will trigger a "Sync is lagging" message to warn of a lagging homeserver. If you run your own HS, setting it to 2000 more than `syncTimeout` will help you diagnose issues. Larger servers like matrix.org often have a 5-10 second lag time, so increase this to prevent your screen filling with lag warnings.
|
||||
* `mxid` is the MXID of your Matrix user
|
||||
* `homeserver` is the URL of your homeserver. You get this value in Element by going to Settings > Help and About > Advanced
|
||||
* `accessToken` is the access token to use. You get this value underneath the homserver URL in Element.
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
"certFile": "reflection.pem",
|
||||
"keyFile": "reflection.key",
|
||||
"lazyLoadLimit": 500,
|
||||
"syncTimeout": 15000,
|
||||
"lagWarningLimit": 20000,
|
||||
"homeserver": "http://localhost:8443",
|
||||
"mxid": "@testing:matrix.org",
|
||||
"accessToken": "asdlfjasdlfkjasdlkfjasdlk",
|
||||
|
|
|
@ -65,12 +65,12 @@ export class Server {
|
|||
|
||||
doSync(): void {
|
||||
if (this.isSyncing) {
|
||||
if ((Date.now() - this.currentSyncTime) > 20000 && this.currentSyncTime > 0)
|
||||
if ((Date.now() - this.currentSyncTime) > this.config.lagWarningLimit && this.currentSyncTime > 0)
|
||||
this.doLog(`Sync is lagging, current sync has been running for ${Date.now() - this.currentSyncTime} milliseconds`);
|
||||
return;
|
||||
}
|
||||
this.isSyncing = true;
|
||||
const endpoint = (this.nextBatch === "") ? "/sync" : `/sync?since=${this.nextBatch}&timeout=15000`;
|
||||
const endpoint = (this.nextBatch === "") ? "/sync" : `/sync?since=${this.nextBatch}&timeout=${this.config.syncTimeout}`;
|
||||
this.currentSyncTime = Date.now();
|
||||
this.apiCall.get(endpoint).then(response => {
|
||||
const data = response.data;
|
||||
|
|
Loading…
Add table
Reference in a new issue