Skip to content

Commit e74a96b

Browse files
committed
FlexServer: check for updates at startup and every week thereafter
We keep track of checking task so that we can disable it later when we have a user interface to enable or disable automated version checks.
1 parent 6aaab3a commit e74a96b

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

app/server/MergedServer.ts

+1
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ export class MergedServer {
194194
await this.flexServer.finalizePlugins(this.hasComponent("home") ? checkUserContentPort() : null);
195195
this.flexServer.checkOptionCombinations();
196196
this.flexServer.summary();
197+
this.flexServer.startCheckingForUpdates();
197198
this.flexServer.ready();
198199
} catch(e) {
199200
await this.flexServer.close();

app/server/lib/FlexServer.ts

+12
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ import {TagChecker} from 'app/server/lib/TagChecker';
7676
import {ITelemetry} from 'app/server/lib/Telemetry';
7777
import {startTestingHooks} from 'app/server/lib/TestingHooks';
7878
import {getTestLoginSystem} from 'app/server/lib/TestLogin';
79+
import {compareWithLatest} from 'app/server/lib/updateChecker';
7980
import {UpdateManager} from 'app/server/lib/UpdateManager';
8081
import {addUploadRoute} from 'app/server/lib/uploads';
8182
import {buildWidgetRepository, getWidgetsInPlugins, IWidgetRepository} from 'app/server/lib/WidgetRepository';
@@ -103,6 +104,9 @@ const HEALTH_CHECK_LOG_SHOW_FIRST_N = 10;
103104
// And we show every Nth health check:
104105
const HEALTH_CHECK_LOG_SHOW_EVERY_N = 100;
105106

107+
// In milliseconds
108+
const ONE_WEEK = 7*24*60*60*1000;
109+
106110
// DocID of Grist doc to collect the Welcome questionnaire responses, such
107111
// as "GristNewUserInfo".
108112
const DOC_ID_NEW_USER_INFO = process.env.DOC_ID_NEW_USER_INFO;
@@ -200,6 +204,7 @@ export class FlexServer implements GristServer {
200204
private _jobs?: GristJobs;
201205
private _emitNotifier = new EmitNotifier();
202206
private _testPendingNotifications: number = 0;
207+
private _intervalCheckID: ReturnType<typeof setInterval>;
203208

204209
constructor(public port: number, public name: string = 'flexServer',
205210
public readonly options: FlexServerOptions = {}) {
@@ -1983,6 +1988,13 @@ export class FlexServer implements GristServer {
19831988
this.create.addExtraHomeEndpoints(this, this.app);
19841989
}
19851990

1991+
public startCheckingForUpdates() {
1992+
const gristServer = this;
1993+
compareWithLatest(gristServer);
1994+
this._intervalCheckID = setInterval(() => {compareWithLatest(gristServer);}, ONE_WEEK);
1995+
log.debug(`started version check task with ID ${this._intervalCheckID}`);
1996+
}
1997+
19861998
// Get the HTML template sent for document pages.
19871999
public async getDocTemplate(): Promise<DocTemplate> {
19882000
const page = await fse.readFile(path.join(getAppPathTo(this.appRoot, 'static'),

0 commit comments

Comments
 (0)