Browse Source

komodod quit via exec

all-modes
pbca26 8 years ago
parent
commit
16107a4644
  1. 4
      main.js
  2. 58
      routes/shepherd.js

4
main.js

@ -121,7 +121,7 @@ server.listen(appConfig.iguanaAppPort, function() {
console.log('guiapp and sockets.io are listening on port ' + appConfig.iguanaAppPort + '!');
});
io.set('origins', 'http://127.0.0.1:' + appConfig.iguanaAppPort); // set origin
io.set('origins', appConfig.dev ? 'http://127.0.0.1:3000' : 'http://127.0.0.1:' + appConfig.iguanaAppPort); // set origin
io.on('connection', function(client) {
console.log('EDEX GUI is connected...');
@ -333,6 +333,8 @@ function createWindow (status) {
return new Promise(function(resolve, reject) {
console.log('Closing Main Window...');
shepherd.quitKomodod();
pm2.connect(true, function(err) {
console.log('connecting to pm2...');

58
routes/shepherd.js

@ -94,6 +94,18 @@ shepherd.appConfig = {
"v2": false
};
shepherd.quitKomodod = function() {
// exit komodod gracefully
console.log('exec ' + komodocliBin + ' stop');
exec(komodocliBin + ' stop', function(error, stdout, stderr) {
console.log('stdout: ' + stdout)
console.log('stderr: ' + stderr)
if (error !== null) {
console.log('exec error: ' + error)
}
});
}
shepherd.saveLocalAppConf = function(appSettings) {
var appConfFileName = iguanaDir + '/config.json';
@ -738,24 +750,36 @@ function herder(flock, data) {
portscanner.checkPortStatus(_port, '127.0.0.1', function(error, status) {
// 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) {
console.error(err);
process.exit(2);
}
pm2.start({
script: komododBin, // path to binary
name: data.ac_name, // REVS, USD, EUR etc.
exec_mode : 'fork',
cwd: komodoDir,
args: data.ac_options
}, function(err, apps) {
pm2.disconnect(); // Disconnect from PM2
if (err)
throw err;
// start komodod via exec
if (data.ac_name === 'komodod') {
console.log('exec' + komododBin + ' -' + data.ac_options.join(' '));
exec(komododBin + ' -' + data.ac_options.join(' '), function(error, stdout, stderr) {
console.log('stdout: ' + stdout)
console.log('stderr: ' + stderr)
if (error !== null) {
console.log('exec error: ' + error)
}
});
});
} else {
pm2.connect(true, function(err) { // start up pm2 god
if (err) {
console.error(err);
process.exit(2);
}
pm2.start({
script: komododBin, // path to binary
name: data.ac_name, // REVS, USD, EUR etc.
exec_mode : 'fork',
cwd: komodoDir,
args: data.ac_options
}, function(err, apps) {
pm2.disconnect(); // Disconnect from PM2
if (err)
throw err;
});
});
}
} else {
console.log('port ' + _port + ' (' + data.ac_name + ') is already in use');
}

Loading…
Cancel
Save