Skip to content

Commit

Permalink
node argv from docker-compose
Browse files Browse the repository at this point in the history
  • Loading branch information
pan261 committed Nov 19, 2021
1 parent 9952585 commit 20e2718
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
4 changes: 1 addition & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ services:
- /ffs/node_modules
ports:
- "3000:3000"
expose:
- "3000"
command: "node server.js"

task_runner_1:
Expand All @@ -21,4 +19,4 @@ services:
- .:/ffs/
- /ffs/node_modules
network_mode: host
command: "node taskRunner.js"
command: "node taskRunner.js lathe"
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const createServer = () => {
res.send(credentials);
} else {
console.log(
'\x1b[91mserver.js::createServer:',
'\x1b[93mserver.js::createServer:',
'\x1b[0m/credentials endpoint called, no credentials found'
);
res.send('Need to authenticate at localhost:3000/auth');
Expand Down
19 changes: 17 additions & 2 deletions taskRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,25 @@ require('dotenv').config();
/**
* This file will be responsible for managing the watcher
* as well as fetching the credentials from the server
* docker-compose will spawn 4 services from this file, each responsible
* for a different folder (gantry, lathe, mill, waterjet)
*/


// TODO
const projectID = ""

// parse command line arguments from docker-compose to get folder ID
const folderIdMap = {
gantry: "GANTRY_FOLDER_ID",
lathe: "LATHE_FOLDER_ID",
mill: "MILL_FOLDER_ID",
waterjet: "WATERJET_FOLDER_ID"
};

const folderID = folderIdMap[process.argv[2]];
console.log(folderID);

const adminProjectID = 'a.YnVzaW5lc3M6cHVyZHVlMjY5NiMyMDIxMTEwODQ2NDQzMzk3Ng';
const adminProjectTopFolder = 'urn:adsk.wipprod:fs.folder:co.ltuYad4ZTtieJLm6j3MGuA';

Expand Down Expand Up @@ -54,8 +71,6 @@ const fetchToken = () => {
* Manages intervals involving getting token from auth server
*/
const getCredentials = () => {
fetchToken();

// on initialization, will wait for credentials from server on 10 sec interval
initInterval = setInterval(() => {
fetchToken();
Expand Down

0 comments on commit 20e2718

Please sign in to comment.