mirror of
https://github.com/qlik-oss/nebula.js.git
synced 2025-12-19 17:58:43 -05:00
refactor: internal packages structure (#94)
* refactor: internal packages structure * refactor: internal packages structure
This commit is contained in:
committed by
GitHub
parent
45eae91837
commit
a57abf1ead
55
commands/serve/lib/engine.js
Normal file
55
commands/serve/lib/engine.js
Normal file
@@ -0,0 +1,55 @@
|
||||
const path = require('path');
|
||||
const execa = require('execa');
|
||||
|
||||
/* eslint no-use-before-define:0 */
|
||||
const startEngine = () => {
|
||||
if (process.env.ACCEPT_EULA == null || process.env.ACCEPT_EULA.toLowerCase() !== 'yes') {
|
||||
throw new Error('Need to accept EULA in order to start engine container');
|
||||
}
|
||||
console.log('Starting engine container ...');
|
||||
return new Promise((resolve, reject) => {
|
||||
const c = execa.command('cross-env ACCEPT_EULA=yes docker-compose up -d --build', {
|
||||
cwd: path.resolve(__dirname, '../'),
|
||||
stdio: 'inherit',
|
||||
shell: true,
|
||||
});
|
||||
|
||||
const ping = setInterval(() => {
|
||||
const { stdout } = execa.command('docker ps -q -f name=engine -f status=running');
|
||||
if (stdout) {
|
||||
console.log('... engine container running');
|
||||
clear();
|
||||
resolve();
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
const timeout = setTimeout(() => {
|
||||
clear();
|
||||
reject();
|
||||
}, 60000);
|
||||
|
||||
function clear() {
|
||||
clearInterval(ping);
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
|
||||
c.on('exit', code => {
|
||||
if (code !== 0) {
|
||||
clear();
|
||||
reject();
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const stopEngine = () => {
|
||||
execa.shellSync('docker-compose down', {
|
||||
cwd: path.resolve(__dirname, '../'),
|
||||
stdio: 'inherit',
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
startEngine,
|
||||
stopEngine,
|
||||
};
|
||||
Reference in New Issue
Block a user