Browse Source

Merge pull request #85 from pbca26/master

too many komodod restarts notification
all-modes
pbca26 8 years ago
committed by GitHub
parent
commit
8be294e3cc
  1. 6
      main.js
  2. 62
      routes/shepherd.js

6
main.js

@ -47,12 +47,12 @@ if (appConfig.killIguanaOnStart) {
}
if (os.platform() === 'win32') {
iguanaGrep = 'tasklist';
}
}
exec(iguanaGrep, function(error, stdout, stderr) {
if (stdout.indexOf('iguana') > -1) {
console.log('found another iguana process(es)');
var pkillCmd = os.platform() === 'win32' ? 'taskkill /f /im iguana.exe' : 'pkill iguana';
exec(pkillCmd, function(error, stdout, stderr) {
console.log(pkillCmd + ' is issued');
if (error !== null) {
@ -68,7 +68,7 @@ if (appConfig.killIguanaOnStart) {
}
guiapp.use(function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*'/*'http://127.0.0.1:' + appConfig.iguanaAppPort*/);
res.header('Access-Control-Allow-Origin', appConfig.dev ? '*' : 'http://127.0.0.1:' + appConfig.iguanaAppPort);
res.header('Access-Control-Allow-Headers', 'X-Requested-With');
res.header('Access-Control-Allow-Credentials', 'true');
res.header('Access-Control-Allow-Headers', 'Content-Type');

62
routes/shepherd.js

@ -88,7 +88,8 @@ shepherd.appConfig = {
"darwin": 90000,
"linux": 1000000
},
"killIguanaOnStart": false
"killIguanaOnStart": false,
"dev": false
};
shepherd.saveLocalAppConf = function(appSettings) {
@ -317,6 +318,23 @@ shepherd.post('/herd', function(req, res) {
};
res.end(JSON.stringify(obj));
if (req.body.herd === 'komodod') {
var _port = assetChainPorts[req.body.options.ac_name];
// check if komodod instance is already running
setTimeout(function() {
portscanner.checkPortStatus(_port, '127.0.0.1', function(error, status) {
// Status is 'open' if currently in use or 'closed' if available
if (status === 'closed') {
cache.io.emit('service', {
'komodod': {
'error': 'start error'
}
});
}
});
}, 10000);
}
});
/*
@ -627,8 +645,10 @@ function herder(flock, data) {
cwd: iguanaDir //set correct iguana directory
}, function(err, apps) {
pm2.disconnect(); // Disconnect from PM2
if (err)
if (err) {
throw err;
console.log('iguana fork error: ' + err);
}
});
});
}
@ -658,7 +678,7 @@ function herder(flock, data) {
try {
// check if komodod instance is already running
portscanner.checkPortStatus(_port, '127.0.0.1', function(error, status) {
// Status is 'open' if currently in use or 'closed' if available
// Status is 'open' if currently in use or 'closed' if available
if (status === 'closed') {
pm2.connect(true, function(err) { // start up pm2 god
if (err) {
@ -673,11 +693,11 @@ function herder(flock, data) {
cwd: komodoDir,
args: data.ac_options
}, function(err, apps) {
pm2.disconnect(); // Disconnect from PM2
if (err)
throw err;
pm2.disconnect(); // Disconnect from PM2
if (err)
throw err;
});
});
});
} else {
console.log('port ' + _port + ' (' + data.ac_name + ') is already in use');
}
@ -705,9 +725,9 @@ function herder(flock, data) {
cwd: zcashDir,
args: data.ac_options
}, function(err, apps) {
pm2.disconnect(); // Disconnect from PM2
if (err)
throw err;
pm2.disconnect(); // Disconnect from PM2
if (err)
throw err;
});
});
}
@ -717,18 +737,18 @@ function herder(flock, data) {
console.log('selected data: ' + data);
pm2.connect(true,function(err) { //start up pm2 god
if (err) {
console.error(err);
process.exit(2);
}
if (err) {
console.error(err);
process.exit(2);
}
pm2.start({
script: CorsProxyBin, // path to binary
name: 'CORSPROXY',
exec_mode : 'fork',
cwd: iguanaDir
}, function(err, apps) {
pm2.disconnect(); // Disconnect from PM2
pm2.start({
script: CorsProxyBin, // path to binary
name: 'CORSPROXY',
exec_mode : 'fork',
cwd: iguanaDir
}, function(err, apps) {
pm2.disconnect(); // Disconnect from PM2
if (err)
throw err;
});

Loading…
Cancel
Save