Browse Source

app config

all-modes
pbca26 8 years ago
parent
commit
b74e0be04b
  1. 10
      main.js
  2. 56
      routes/shepherd.js

10
main.js

@ -26,8 +26,13 @@ var express = require('express'),
Promise = require('bluebird');
app.setName('Agama');
app.setVersion('0.1.6.2e-beta');
const appBasicInfo = {
name: 'Agama',
version: '0.1.6.2e-beta'
};
app.setName(appBasicInfo.name);
app.setVersion(appBasicInfo.version);
if (os.platform() === 'linux') {
process.env.ELECTRON_RUN_AS_NODE = true;
@ -140,6 +145,7 @@ io.on('connection', function(client) {
});
shepherd.setIO(io); // pass sockets object to shepherd router
shepherd.setVar('appBasicInfo', appBasicInfo);
module.exports = guiapp;
// END GUI App Settings

56
routes/shepherd.js

@ -292,20 +292,38 @@ console.log('iguana dir: ' + komododBin);
console.log('iguana bin: ' + komodoDir);
// END IGUANA FILES AND CONFIG SETTINGS
// default route
shepherd.get('/', function(req, res, next) {
res.send('Iguana app server');
});
/*
* type: GET
*
*/
shepherd.get('/appconf', function(req, res, next) {
var obj = shepherd.loadLocalConfig();
res.send(obj);
});
/*
* type: GET
*
*/
shepherd.get('/sysinfo', function(req, res, next) {
var obj = shepherd.SystemInfo();
res.send(obj);
});
/*
* type: GET
*
*/
shepherd.get('/appinfo', function(req, res, next) {
var obj = shepherd.appInfo();
res.send(obj);
});
shepherd.dumpCacheBeforeExit = function() {
cache.dumpCacheBeforeExit();
}
@ -319,6 +337,10 @@ shepherd.setIO = function(io) {
cache.setVar('io', io);
};
shepherd.setVar = function(_name, _body) {
shepherd[_name] = _body;
};
cache.setVar('iguanaDir', iguanaDir);
cache.setVar('appConfig', shepherd.appConfig);
@ -1388,4 +1410,38 @@ shepherd.SystemInfo = function() {
return os_data;
}
shepherd.SystemInfo = function() {
const os_data = {
'totalmem_bytes': os.totalmem(),
'totalmem_readable': formatBytes(os.totalmem()),
'arch': os.arch(),
'cpu': os.cpus()[0].model,
'cpu_cores': os.cpus().length,
'platform': os.platform(),
'os_release': os.release(),
'os_type': os.type()
};
return os_data;
}
shepherd.appInfo = function() {
const sysInfo = shepherd.SystemInfo();
const releaseInfo = shepherd.appBasicInfo;
const dirs = {
iguanaDir,
iguanaBin,
komodoDir,
komododBin
configLocation: iguanaDir + '/config.json',
cacheLocation: iguanaDir + '/shepherd',
};
return {
sysInfo,
releaseInfo,
dirs,
};
}
module.exports = shepherd;
Loading…
Cancel
Save