diff --git a/src/app.js b/src/app.js index 98e6112..2ff3cc3 100644 --- a/src/app.js +++ b/src/app.js @@ -41,7 +41,8 @@ function handleNewFile(filePath, queue, metricsLogger) { } async function start() { - console.log('Starting Animl Base'); + console.log('---------------------------------\n'); + console.log('\nStarting Animl Base'); // Starting Buckeye software let mbase = new Multibase(config); @@ -58,16 +59,19 @@ async function start() { // Initialize directory watcher const imgWatcher = chokidar.watch(config.imgDir, config.watcher); imgWatcher - .on('ready', () => console.log(`Watching for changes to ${config.imgDir}`)) + .on('ready', async () => { + console.log(`Watching for changes to ${config.imgDir}`); + + // NOTE: just for testing + // const filesWatchedOnStart = imgWatcher.getWatched(); + // Object.keys(filesWatchedOnStart).forEach((dir) => { + // console.log(`Number of files in ${dir} ON START: ${filesWatchedOnStart[dir].length}`); + // console.log(`First image in directory: ${filesWatchedOnStart[dir][0]}`); + // }); + }) .on('add', (path) => handleNewFile(path, queue, metricsLogger)) .on('error', (err) => console.log(`imgWatcher error: ${err}`)); - // // Just for testing... - // const filesWatched = imgWatcher.getWatched(); - // Object.keys(filesWatched).forEach((dir) => { - // console.log(`Number of files in ${dir} : ${filesWatched[dir].length}`); - // }); - // Initialize worker let worker = new Worker(config, queue, imgWatcher); await worker.init(); diff --git a/src/utils/multibase.js b/src/utils/multibase.js index 16702ba..c47f64d 100644 --- a/src/utils/multibase.js +++ b/src/utils/multibase.js @@ -10,16 +10,9 @@ class Multibase { const output = { out: [], err: [], exitCode: null }; const opts = { shell: true }; const mbase = args ? spawn(cmd, args, opts) : spawn(cmd, opts); - mbase.stdout.on('data', (data) => { - console.log('mbase stdout: ', data.toString()); - output.out.push(data.toString()); - }); - mbase.stderr.on('data', (data) => { - console.error('mbase stderr: ', data.toString()); - output.err.push(data.toString()); - }); + mbase.stdout.on('data', (data) => output.out.push(data.toString())); + mbase.stderr.on('data', (data) => output.err.push(data.toString())); mbase.on('exit', (code) => { - console.log(`mbase exited with code ${code}`); output.exitCode = code; resolve(output); }); @@ -36,16 +29,16 @@ class Multibase { running = false; } } - console.log('Multibase SE running? ', running); return running; } } async start() { if (this.config.platform === 'linux') { - console.log('Linux detected, starting Buckeye Multibase SE'); + console.log('Linux detected, checking Buckeye Multibase SE state...'); const running = await this.isRunning(); if (!running) { + console.log('Starting Buckeye Multibase SE...'); await this.exec('mbasectl', ['-s']); } } else if (this.config.platform === 'win32') { diff --git a/src/utils/worker.js b/src/utils/worker.js index 1759ac8..ffa4bc7 100644 --- a/src/utils/worker.js +++ b/src/utils/worker.js @@ -29,18 +29,13 @@ class Worker { try { // get first job & process console.log('Queue length: ', this.queue.size); + const img = await this.queue.getFirst(); await this.s3.upload(img.path); console.log('Upload success'); await this.queue.remove(img.path); await this.imgWatcher.unwatch(img.path); // TODO: test whether this works - // // Just for testing... - // const filesWatched = this.imgWatcher.getWatched(); - // Object.keys(filesWatched).forEach((dir) => { - // console.log(`Number of files in ${dir} : ${filesWatched[dir].length}`); - // }); - // Reset backoff and poll again this.backoff.reset(); this.poll();