-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMPROVE] Connectivity Services License Sync (#15022)
* Add workspace sync to cron job to keep license, access token, and marketplace key in sync
- Loading branch information
1 parent
0c244c5
commit 30d671b
Showing
2 changed files
with
23 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,33 @@ | ||
import { Meteor } from 'meteor/meteor'; | ||
import { SyncedCron } from 'meteor/littledata:synced-cron'; | ||
|
||
import './methods'; | ||
import { getWorkspaceAccessToken } from './functions/getWorkspaceAccessToken'; | ||
import { getWorkspaceLicense } from './functions/getWorkspaceLicense'; | ||
import { getUserCloudAccessToken } from './functions/getUserCloudAccessToken'; | ||
import { getWorkspaceKey } from './functions/getWorkspaceKey'; | ||
import { syncWorkspace } from './functions/syncWorkspace'; | ||
import { Permissions } from '../../models'; | ||
|
||
if (Permissions) { | ||
Permissions.createOrUpdate('manage-cloud', ['admin']); | ||
} | ||
|
||
// Ensure the client/workspace access token is valid | ||
getWorkspaceAccessToken(); | ||
const licenseCronName = 'Cloud Workspace Sync'; | ||
|
||
Meteor.startup(function() { | ||
// run token/license sync if registered | ||
syncWorkspace(); | ||
|
||
SyncedCron.remove(licenseCronName); | ||
SyncedCron.add({ | ||
name: licenseCronName, | ||
schedule(parser) { | ||
// Every 12 hours | ||
return parser.cron('0 */12 * * *'); | ||
}, | ||
job: syncWorkspace, | ||
}); | ||
}); | ||
|
||
export { getWorkspaceAccessToken, getWorkspaceLicense, getWorkspaceKey, getUserCloudAccessToken }; |