mirror of
https://github.com/nuintun/command-manager.git
synced 2025-06-07 03:14:07 +08:00
update files
This commit is contained in:
parent
1b8e084879
commit
12e9d713c5
@ -9,8 +9,20 @@ var Emulator = require('./emulator');
|
||||
var emulator;
|
||||
|
||||
// thread
|
||||
process.on('message', function (project){
|
||||
process.on('message', function (message){
|
||||
if (message.action === 'stop') {
|
||||
if (emulator) {
|
||||
emulator.stop();
|
||||
}
|
||||
|
||||
process.exit();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.action === 'start') {
|
||||
var stream;
|
||||
var project = message.project;
|
||||
|
||||
if (emulator) {
|
||||
emulator.stop();
|
||||
@ -48,4 +60,5 @@ process.on('message', function (project){
|
||||
data: signal.toString()
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -26,7 +26,13 @@ Emulator.prototype = {
|
||||
},
|
||||
stop: function (){
|
||||
if (this.thread) {
|
||||
this.thread.kill('SIGTERM');
|
||||
this.thread.kill('SIGKILL');
|
||||
|
||||
['stdin', 'stdout', 'stderr'].forEach(function (stream){
|
||||
this.thread[stream].removeAllListeners();
|
||||
}, this);
|
||||
|
||||
this.thread = null;
|
||||
}
|
||||
},
|
||||
exec: function (){
|
||||
|
@ -19,7 +19,9 @@ function killThread(name){
|
||||
var thread = threads[name];
|
||||
|
||||
if (thread && thread.connected) {
|
||||
thread.kill('SIGTERM');
|
||||
thread.send({
|
||||
action: 'stop'
|
||||
});
|
||||
|
||||
delete threads[name];
|
||||
}
|
||||
@ -28,8 +30,7 @@ function killThread(name){
|
||||
module.exports = {
|
||||
start: function (){
|
||||
ipc.on('emulator', function (event, project, action){
|
||||
var key = project.name + '-' + project.command.name;
|
||||
var thread = threads[key];
|
||||
var thread = threads[project.name];
|
||||
|
||||
switch (action) {
|
||||
case 'start':
|
||||
@ -58,13 +59,19 @@ module.exports = {
|
||||
|
||||
delete project.env;
|
||||
|
||||
thread.send(project);
|
||||
thread.send({
|
||||
action: 'start',
|
||||
project: project
|
||||
});
|
||||
|
||||
threads[project.name] = thread;
|
||||
} else {
|
||||
delete project.env;
|
||||
|
||||
thread.send(project);
|
||||
thread.send({
|
||||
action: 'start',
|
||||
project: project
|
||||
});
|
||||
}
|
||||
break;
|
||||
case 'stop':
|
||||
|
Loading…
x
Reference in New Issue
Block a user