Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3242403
D13135.id43562.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D13135.id43562.diff
View Options
diff --git a/keyserver/src/cron/cron.js b/keyserver/src/cron/cron.js
--- a/keyserver/src/cron/cron.js
+++ b/keyserver/src/cron/cron.js
@@ -28,9 +28,14 @@
import { deleteUnassignedUploads } from '../deleters/upload-deleters.js';
import { fetchCallUpdateOlmAccount } from '../updaters/olm-account-updater.js';
import { validateAndUploadAccountPrekeys } from '../utils/olm-utils.js';
-import { isPrimaryNode } from '../utils/primary-secondary-utils.js';
+import {
+ isPrimaryNode,
+ isAuxiliaryNode,
+} from '../utils/primary-secondary-utils.js';
import { synchronizeInviteLinksWithBlobs } from '../utils/synchronize-invite-links-with-blobs.js';
+const { RUN_COMM_TEAM_DEV_SCRIPTS } = process.env;
+
if (cluster.isMaster) {
schedule.scheduleJob(
'0 3 ? * 0', // every Sunday at 3:00 AM in the keyserver's timezone
@@ -73,12 +78,16 @@
},
);
schedule.scheduleJob(
- '0 */4 * * *', // every four hours
+ '0 5 * * *', // every day at 5:00 AM in the keyserver's timezone
async () => {
try {
- await backupDB();
+ await updateIdentityReservedUsernames();
} catch (e) {
- console.warn('encountered error while trying to backup database', e);
+ console.warn(
+ 'encountered error while trying to update reserved usernames on ' +
+ 'identity service',
+ e,
+ );
}
},
);
@@ -86,74 +95,68 @@
'0 0 * * *', // every day at midnight in the keyserver's timezone
async () => {
try {
- if (process.env.RUN_COMM_TEAM_DEV_SCRIPTS) {
- // This is a job that the Comm internal team uses
- await createDailyUpdatesThread();
- }
- } catch (e) {
- console.warn(
- 'encountered error while trying to create daily updates thread',
- e,
+ await fetchCallUpdateOlmAccount(
+ 'content',
+ (contentAccount: OlmAccount) =>
+ fetchCallUpdateOlmAccount(
+ 'notifications',
+ (notifAccount: OlmAccount) =>
+ validateAndUploadAccountPrekeys(contentAccount, notifAccount),
+ ),
);
+ } catch (e) {
+ console.warn('encountered error while trying to validate prekeys', e);
}
},
);
schedule.scheduleJob(
- '0 0 8 * *', // 8th of every month at midnight in the keyserver's timezone
+ '0 2 * * *', // every day at 2:00 AM in the keyserver's timezone
async () => {
try {
- if (process.env.RUN_COMM_TEAM_DEV_SCRIPTS) {
- // This is a job that the Comm internal team uses
- await postLeaderboard();
- }
+ await synchronizeInviteLinksWithBlobs();
} catch (e) {
console.warn(
- 'encountered error while trying to post Phabricator leaderboard',
+ 'encountered an error while trying to synchronize invite links with blobs',
e,
);
}
},
);
+ }
+ if (isPrimaryNode || isAuxiliaryNode) {
schedule.scheduleJob(
- '0 5 * * *', // every day at 5:00 AM in the keyserver's timezone
+ '0 */4 * * *', // every four hours
async () => {
try {
- await updateIdentityReservedUsernames();
+ await backupDB();
} catch (e) {
- console.warn(
- 'encountered error while trying to update reserved usernames on ' +
- 'identity service',
- e,
- );
+ console.warn('encountered error while trying to backup database', e);
}
},
);
+ }
+ if (RUN_COMM_TEAM_DEV_SCRIPTS && (isPrimaryNode || isAuxiliaryNode)) {
schedule.scheduleJob(
'0 0 * * *', // every day at midnight in the keyserver's timezone
async () => {
try {
- await fetchCallUpdateOlmAccount(
- 'content',
- (contentAccount: OlmAccount) =>
- fetchCallUpdateOlmAccount(
- 'notifications',
- (notifAccount: OlmAccount) =>
- validateAndUploadAccountPrekeys(contentAccount, notifAccount),
- ),
- );
+ await createDailyUpdatesThread();
} catch (e) {
- console.warn('encountered error while trying to validate prekeys', e);
+ console.warn(
+ 'encountered error while trying to create daily updates thread',
+ e,
+ );
}
},
);
schedule.scheduleJob(
- '0 2 * * *', // every day at 2:00 AM in the keyserver's timezone
+ '0 0 8 * *', // 8th of every month at midnight in the keyserver's timezone
async () => {
try {
- await synchronizeInviteLinksWithBlobs();
+ await postLeaderboard();
} catch (e) {
console.warn(
- 'encountered an error while trying to synchronize invite links with blobs',
+ 'encountered error while trying to post Phabricator leaderboard',
e,
);
}
diff --git a/keyserver/src/utils/primary-secondary-utils.js b/keyserver/src/utils/primary-secondary-utils.js
--- a/keyserver/src/utils/primary-secondary-utils.js
+++ b/keyserver/src/utils/primary-secondary-utils.js
@@ -7,3 +7,7 @@
export const isSecondaryNode: boolean = process.env.COMM_NODE_ROLE
? process.env.COMM_NODE_ROLE === 'secondary'
: false;
+
+export const isAuxiliaryNode: boolean = process.env.COMM_NODE_ROLE
+ ? process.env.COMM_NODE_ROLE === 'auxiliary'
+ : false;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 14, 9:01 PM (11 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2492868
Default Alt Text
D13135.id43562.diff (5 KB)
Attached To
Mode
D13135: [keyserver] Introduce concept of auxiliary node for running certain cronjobs
Attached
Detach File
Event Timeline
Log In to Comment