Run initial docker build in parallel

This commit is contained in:
1computer1 2019-03-12 23:21:05 -04:00
parent 0fa062875b
commit 0d29b8f403
2 changed files with 8 additions and 5 deletions

View file

@ -31,7 +31,7 @@ class CompilerClient extends AkairoClient {
this.config = config;
}
start() {
async start() {
this.commandHandler.useListenerHandler(this.listenerHandler);
this.listenerHandler.setEmitters({
commandHandler: this.commandHandler,
@ -42,7 +42,7 @@ class CompilerClient extends AkairoClient {
this.commandHandler.loadAll();
this.listenerHandler.loadAll();
this.languageHandler.loadAll();
this.languageHandler.buildDocker();
await this.languageHandler.buildDocker();
return this.login(this.config.token);
}
}

View file

@ -2,6 +2,8 @@ const { AkairoHandler } = require('discord-akairo');
const { Collection } = require('discord.js');
const Language = require('./Language');
const childProcess = require('child_process');
const util = require('util');
const path = require('path');
class LanguageHandler extends AkairoHandler {
constructor(client, {
@ -48,9 +50,10 @@ class LanguageHandler extends AkairoHandler {
}
buildDocker() {
for (const [, { id }] of this.modules) {
childProcess.execSync(`docker build -t "1computer1/comp_iler:${id}" ./docker/${id}`);
}
return Promise.all(this.modules.map(({ id }) => {
const folder = path.join(__dirname, '../../docker', id);
return util.promisify(childProcess.exec)(`docker build -t "1computer1/comp_iler:${id}" ${folder}`);
}));
}
evalCode(message, { language, code, options }) {