now forking a seperate process to work when node is busy

This commit is contained in:
Philipp Kunz 2016-05-23 04:40:04 +02:00
parent 7f4adbfe9f
commit 1ceae01a49
6 changed files with 128 additions and 109 deletions

0
dist/early.child.d.ts vendored Normal file
View File

54
dist/early.child.js vendored Normal file
View File

@ -0,0 +1,54 @@
"use strict";
/// <reference path="./typings/index.d.ts" />
var colors = require("colors");
var readline = require("readline");
var rl;
var initReadline = function () {
rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
};
var moduleName;
var loaderLength;
var frameCounter = 0;
var makeFrame = function () {
var resultString = "["
+ "/".green.repeat(frameCounter)
+ " ".repeat(loaderLength - frameCounter)
+ "]"
+ " starting "
+ moduleName.cyan;
if (frameCounter == loaderLength) {
frameCounter = 0;
}
else {
frameCounter++;
}
return resultString;
};
var logEarly = function () {
rl.write(null, { ctrl: true, name: 'u' });
rl.write(makeFrame());
setTimeout(function () {
logEarly();
}, 200);
};
var start = function (moduleNameArg, loaderLengthArg) {
if (moduleNameArg === void 0) { moduleNameArg = ""; }
if (loaderLengthArg === void 0) { loaderLengthArg = "10"; }
console.log(moduleNameArg);
moduleName = moduleNameArg;
loaderLength = parseInt(loaderLengthArg);
if (!process.env.CI) {
initReadline();
logEarly();
}
else {
console.log("**** starting " + moduleName.cyan + " ****");
}
;
};
start(process.env.moduleNameArg, process.env.loaderLengthArg);
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImVhcmx5LmNoaWxkLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSw2Q0FBNkM7QUFDN0MsSUFBSSxNQUFNLEdBQUcsT0FBTyxDQUFDLFFBQVEsQ0FBQyxDQUFDO0FBQy9CLElBQU8sUUFBUSxXQUFXLFVBQVUsQ0FBQyxDQUFDO0FBQ3RDLElBQUksRUFBRSxDQUFDO0FBQ1AsSUFBSSxZQUFZLEdBQUc7SUFDZixFQUFFLEdBQUcsUUFBUSxDQUFDLG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ID0gXCIxMFwiKXtcclxuICAgIGNvbnNvbGUubG9nKG1vZHVsZU5hbWVBcmcpO1xyXG4gICAgbW9kdWxlTmFtZSA9IG1vZHVsZU5hbWVBcmc7XHJcbiAgICBsb2FkZXJMZW5ndGggPSBwYXJzZUludChsb2FkZXJMZW5ndGhBcmcpO1xyXG4gICAgaWYgKCFwcm9jZXNzLmVudi5DSSl7XHJcbiAgICAgICAgaW5pdFJlYWRsaW5lKCk7XHJcbiAgICAgICAgbG9nRWFybHkoKTtcclxuICAgIH0gZWxzZSB7XHJcbiAgICAgICAgY29uc29sZS5sb2coXCIqKioqIHN0YXJ0aW5nIFwiICsgbW9kdWxlTmFtZS5jeWFuICsgXCIgKioqKlwiKTtcclxuICAgIH07XHJcbn07XHJcblxyXG5zdGFydChwcm9jZXNzLmVudi5tb2R1bGVOYW1lQXJnLHByb2Nlc3MuZW52LmxvYWRlckxlbmd0aEFyZyk7Il19

2
dist/index.d.ts vendored
View File

@ -1,2 +1,2 @@
export declare let start: (moduleNameArg?: string, loaderLengthArg?: number) => void;
export declare let start: (moduleNameArg?: string, loaderLengthArg?: string) => void;
export declare let stop: () => void;

64
dist/index.js vendored
View File

@ -2,63 +2,21 @@
/// <reference path="./typings/index.d.ts" />
var colors = require("colors");
var readline = require("readline");
var rl;
var initReadline = function () {
rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
};
var moduleName;
var loaderLength;
var frameCounter = 0;
var makeFrame = function () {
var resultString = "["
+ "/".green.repeat(frameCounter)
+ " ".repeat(loaderLength - frameCounter)
+ "]"
+ " starting "
+ moduleName.cyan;
if (frameCounter == loaderLength) {
frameCounter = 0;
}
else {
frameCounter++;
}
return resultString;
};
var abort = true;
var logEarly = function () {
rl.write(null, { ctrl: true, name: 'u' });
rl.write(makeFrame());
setTimeout(function () {
if (!abort) {
logEarly();
}
}, 200);
};
var childProcess = require("child_process");
var earlyChild;
// exports
exports.start = function (moduleNameArg, loaderLengthArg) {
if (moduleNameArg === void 0) { moduleNameArg = ""; }
if (loaderLengthArg === void 0) { loaderLengthArg = 10; }
abort = false;
moduleName = moduleNameArg;
loaderLength = loaderLengthArg;
if (!process.env.CI) {
initReadline();
logEarly();
}
else {
console.log("**** starting " + moduleName.cyan + " ****");
}
;
if (loaderLengthArg === void 0) { loaderLengthArg = "10"; }
earlyChild = childProcess.fork("./dist/early.child.js", [], {
env: {
moduleNameArg: moduleNameArg,
loaderLengthArg: loaderLengthArg
}
});
};
exports.stop = function () {
abort = true;
if (!process.env.CI) {
rl.write(null, { ctrl: true, name: 'u' });
rl.close();
}
earlyChild.kill();
};
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSw2Q0FBNkM7QUFDN0MsSUFBSSxNQUFNLEdBQUcsT0FBTyxDQUFDLFFBQVEsQ0FBQyxDQUFDO0FBQy9CLElBQUksUUFBUSxHQUFHLE9BQU8sQ0FBQyxVQUFVLENBQUMsQ0FBQztBQUVuQyxJQUFJLEVBQUUsQ0FBQztBQUNQLElBQUksWUFBWSxHQUFHO0lBQ2YsRUFBRSxHQUFHLFFBQVEsQ0FBQyxlQUFlLENBQUM7UUFDOUIsS0FBSyxFQUFFLE9BQU8sQ0FBQyxLQUFLO1FBQ3BCLE1BQU0sRUFBRSxPQUFPLENBQUMsTUFBTTtLQUNyQixDQUFDLENBQUM7QUFDUCxDQUFDLENBQUM7QUFFRixJQUFJLFVBQWlCLENBQUM7QUFDdEIsSUFBSSxZQUFtQixDQUFDO0FBQ3hCLElBQUksWUFBWSxHQUFVLENBQUMsQ0FBQztBQUU1QixJQUFJLFNBQVMsR0FBRztJQUNaLElBQUksWUFBWSxHQUFVLEdBQUc7VUFDdkIsR0FBRyxDQUFDLEtBQUssQ0FBQyxNQUFNLENBQUMsWUFBWSxDQUFDO1VBQzlCLEdBQUcsQ0FBQyxNQUFNLENBQUMsWUFB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gICBlYXJseUNoaWxkLmtpbGwoKTtcclxufTtcclxuXHJcbiJdfQ==

52
ts/early.child.ts Normal file
View File

@ -0,0 +1,52 @@
/// <reference path="./typings/index.d.ts" />
let colors = require("colors");
import readline = require("readline");
let rl;
let initReadline = () => {
rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
};
let moduleName:string;
let loaderLength:number;
let frameCounter:number = 0;
let makeFrame = ():string => {
let resultString:string = "["
+ "/".green.repeat(frameCounter)
+ " ".repeat(loaderLength - frameCounter)
+ "]"
+ " starting "
+ moduleName.cyan;
if(frameCounter == loaderLength){
frameCounter = 0;
} else {
frameCounter++;
}
return resultString;
};
let logEarly = () => {
rl.write(null, {ctrl: true, name: 'u'});
rl.write(makeFrame());
setTimeout(function(){
logEarly();
},200);
};
let start = function(moduleNameArg:string = "",loaderLengthArg:string = "10"){
console.log(moduleNameArg);
moduleName = moduleNameArg;
loaderLength = parseInt(loaderLengthArg);
if (!process.env.CI){
initReadline();
logEarly();
} else {
console.log("**** starting " + moduleName.cyan + " ****");
};
};
start(process.env.moduleNameArg,process.env.loaderLengthArg);

View File

@ -2,64 +2,19 @@
let colors = require("colors");
let readline = require("readline");
let rl;
let initReadline = () => {
rl = readline.createInterface({
input: process.stdin,
output: process.stdout
import childProcess = require("child_process");
let earlyChild;
// exports
export let start = function(moduleNameArg:string = "",loaderLengthArg:string = "10"){
earlyChild = childProcess.fork("./dist/early.child.js",[],{
env: {
moduleNameArg:moduleNameArg,
loaderLengthArg:loaderLengthArg
}
});
};
let moduleName:string;
let loaderLength:number;
let frameCounter:number = 0;
let makeFrame = ():string => {
let resultString:string = "["
+ "/".green.repeat(frameCounter)
+ " ".repeat(loaderLength - frameCounter)
+ "]"
+ " starting "
+ moduleName.cyan;
if(frameCounter == loaderLength){
frameCounter = 0;
} else {
frameCounter++;
}
return resultString;
};
let abort:boolean = true;
let logEarly = () => {
rl.write(null, {ctrl: true, name: 'u'});
rl.write(makeFrame());
setTimeout(function(){
if(!abort){
logEarly();
}
},200);
};
// exports
export let start = function(moduleNameArg:string = "",loaderLengthArg:number = 10){
abort = false;
moduleName = moduleNameArg;
loaderLength = loaderLengthArg;
if (!process.env.CI){
initReadline();
logEarly();
} else {
console.log("**** starting " + moduleName.cyan + " ****");
};
};
export let stop = function(){
abort = true;
if (!process.env.CI){
rl.write(null, {ctrl: true, name: 'u'});
rl.close();
}
earlyChild.kill();
};