Browse Source

read app version from local file

all-modes
pbca26 8 years ago
parent
commit
384101915c
  1. 15
      main.js
  2. 37
      routes/shepherd.js

15
main.js

@ -28,9 +28,19 @@ var express = require('express'),
Promise = require('bluebird');
// read app version
const localVersionFile = fs.readFileSync(`version`, 'utf8');
let localVersion;
if (localVersionFile.indexOf('\r\n') > -1) {
localVersion = localVersionFile.split('\r\n');
} else {
localVersion = localVersionFile.split('\n');
}
const appBasicInfo = {
name: 'Agama',
version: '0.2.0.21a-beta'
version: localVersion[0],
};
app.setName(appBasicInfo.name);
@ -81,7 +91,7 @@ if (appConfig.killIguanaOnStart) {
iguanaGrep = 'tasklist';
break;
}
exec(iguanaGrep, function(error, stdout, stderr) {
if (stdout.indexOf('iguana') > -1) {
const pkillCmd = osPlatform === 'win32' ? 'taskkill /f /im iguana.exe' : 'pkill -15 iguana';
@ -300,6 +310,7 @@ function createWindow (status) {
if (appConfig.v2) {
shepherd.writeLog('show edex gui');
mainWindow.appConfig = appConfig;
mainWindow.appBasicInfo = appBasicInfo;
mainWindow.appSessionHash = appSessionHash;
if (appConfig.dev) {

37
routes/shepherd.js

@ -1163,13 +1163,29 @@ shepherd.post('/forks', function(req, res, next) {
args: [`-port=${_port}`],
cwd: iguanaDir //set correct iguana directory
}, function(err, apps) {
iguanaInstanceRegistry[_port] = {
'mode': mode,
'coin': coin,
'pid': apps[0].process && apps[0].process.pid,
'pmid': apps[0].pm2_env.pm_id
};
cache.setVar('iguanaInstances', iguanaInstanceRegistry);
if (apps && apps[0] && apps[0].process && apps[0].process.pid) {
iguanaInstanceRegistry[_port] = {
'mode': mode,
'coin': coin,
'pid': apps[0].process && apps[0].process.pid,
'pmid': apps[0].pm2_env.pm_id
};
cache.setVar('iguanaInstances', iguanaInstanceRegistry);
const successObj = {
'msg': 'success',
'result': _port
};
res.end(JSON.stringify(successObj));
} else {
const errorObj = {
'msg': 'success',
'error': 'iguana start error'
};
res.end(JSON.stringify(errorObj));
}
// get sync only forks info
if (syncOnlyInstanceInterval === -1) {
@ -1181,13 +1197,6 @@ shepherd.post('/forks', function(req, res, next) {
}, 20000);
}
const successObj = {
'msg': 'success',
'result': _port
};
res.end(JSON.stringify(successObj));
pm2.disconnect(); // Disconnect from PM2
if (err) {
shepherd.writeLog(`iguana fork error: ${err}`);

Loading…
Cancel
Save