Skip to content

Commit

Permalink
task runner inital setup
Browse files Browse the repository at this point in the history
  • Loading branch information
pan261 committed Nov 18, 2021
1 parent 2759576 commit 757236b
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 19 deletions.
19 changes: 0 additions & 19 deletions manager.js

This file was deleted.

50 changes: 50 additions & 0 deletions taskRunner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const axios = require('axios');
const watcher = require('./watcher');
require('dotenv').config();

/**
* This file will be responsible for managing the watcher
* as well as ensuring the credentials are avaiable
* */

const projectID = "a.YnVzaW5lc3M6cHVyZHVlMjY5NiMyMDIxMTEwODQ2NDQzMzk3Ng";

var credentials = null;
var initInterval = null;
var updateInterval = null;

const fetchToken = () => {
axios({
method: 'GET',
url: 'http://localhost:3000/credentials'
})
.then(res => {
// console.log(res.data);
if (Object.keys(res.data).length == 5) {
credentials = res.data;
clearInterval(initInterval);
console.log("credentials received");
}
})
.catch(err => {
console.log(err);
});
}

fetchToken();
initInterval = setInterval(() => {
fetchToken();
console.log("waiting for initial auth")
}, 10000);
updateInterval = setInterval(fetchToken, 3300 * 1000);


const dispatchWatcher = () => {
if (credentials == null) {
console.log("no credentials");
} else {
watcher.watch(projectID, 'urn:adsk.wipprod:fs.folder:co.ltuYad4ZTtieJLm6j3MGuA', credentials, 5);
}
}

setInterval(dispatchWatcher, 5000)

0 comments on commit 757236b

Please sign in to comment.