Browse Source

move config to iguana folder (wip)

all-modes
Petr Balashov 8 years ago
parent
commit
a25b1992c3
  1. 4
      gui/index.html
  2. 3
      gui/init.js
  3. 2
      gui/loading.js
  4. 30
      pull-gui.sh
  5. 42
      routes/shepherd.js

4
gui/index.html

@ -10,10 +10,6 @@
<script type="text/javascript" src="loading.js"></script> <script type="text/javascript" src="loading.js"></script>
<script type="text/javascript" src="jRoll.min.js"></script> <script type="text/javascript" src="jRoll.min.js"></script>
<script>if (window.module) module = window.module;</script> <script>if (window.module) module = window.module;</script>
<script type="text/javascript">
const remote = require('electron').remote;
var window = remote.getCurrentWindow();
</script>>
</head> </head>
<body style="overflow:hidden;"> <body style="overflow:hidden;">
<div style="text-align: center;"> <div style="text-align: center;">

3
gui/init.js

@ -1,4 +1,7 @@
$(document).ready(function() { $(document).ready(function() {
const remote = require('electron').remote;
var window = remote.getCurrentWindow();
$('#pulse').jRoll({ $('#pulse').jRoll({
radius: 100, radius: 100,
animation: 'pulse' animation: 'pulse'

2
gui/loading.js

@ -92,7 +92,7 @@ function EDEX_DEXnotarychains() {
'agent': 'dpow', 'agent': 'dpow',
'method': 'notarychains' 'method': 'notarychains'
}, },
AjaxOutputData = IguanaAJAX('http://127.0.0.1:7778',ajax_data).done(function(data) { AjaxOutputData = IguanaAJAX('http://127.0.0.1:7778', ajax_data).done(function(data) {
//console.log(AjaxOutputData.responseText); //console.log(AjaxOutputData.responseText);
AjaxOutputData = JSON.parse(AjaxOutputData.responseText); AjaxOutputData = JSON.parse(AjaxOutputData.responseText);
//console.log(AjaxOutputData); //console.log(AjaxOutputData);

30
pull-gui.sh

@ -14,25 +14,23 @@ else
git clone https://github.com/SuperNETorg/EasyDEX-GUI.git git clone https://github.com/SuperNETorg/EasyDEX-GUI.git
fi fi
if [ -d "Iguana-application" ]; then #if [ -d "Iguana-application" ]; then
cd Iguana-application # cd Iguana-application
git checkout 0.3.1 # git checkout 0.3.1
git branch 0.3.1 --track origin/0.3.1 # git pull
git pull #else
else # git clone https://github.com/SuperNETorg/Iguana-application.git -b 0.3.1
git clone https://github.com/SuperNETorg/Iguana-application.git -b 0.3.1 # cd Iguana-application
cd Iguana-application #fi
git branch 0.3.1 --track origin/0.3.1
fi
bower install #bower install
npm install #npm install
gulp electron #gulp electron
cd ../../ cd ../../
rm "gui/EasyDEX-GUI" -rf rm "gui/EasyDEX-GUI" -rf
rm "gui/Iguana-GUI" -rf #rm "gui/Iguana-GUI" -rf
cp -rf "tmp/Iguana-application/compiled/prod" "gui/Iguana-GUI" #cp -rf "tmp/Iguana-application/compiled/prod" "gui/Iguana-GUI"
cp -rf "tmp/EasyDEX-GUI" "gui/EasyDEX-GUI" cp -rf "tmp/EasyDEX-GUI" "gui/EasyDEX-GUI"

42
routes/shepherd.js

@ -61,13 +61,14 @@ console.log(iguanaBin);
// END IGUANA FILES AND CONFIG SETTINGS // END IGUANA FILES AND CONFIG SETTINGS
shepherd.get('/', function(req, res, next) { shepherd.get('/', function(req, res, next) {
res.send('Iguana app server') res.send('Iguana app server');
}) });
shepherd.get('/appconf', function(req, res, next) { shepherd.get('/appconf', function(req, res, next) {
saveLocalAppConf();
var obj = JSON.parse(fs.readFileSync('config.json', 'utf8')); var obj = JSON.parse(fs.readFileSync('config.json', 'utf8'));
res.send(obj); res.send(obj);
}) });
shepherd.post('/herd', function(req, res) { shepherd.post('/herd', function(req, res) {
console.log('======= req.body ======='); console.log('======= req.body =======');
@ -93,7 +94,8 @@ shepherd.post('/herdlist', function(req, res) {
pm2.describe(req.body.herdname, function(err, list) { pm2.describe(req.body.herdname, function(err, list) {
pm2.disconnect(); // disconnect after getting proc info list pm2.disconnect(); // disconnect after getting proc info list
if (err) throw err // TODO: proper error handling if (err)
throw err; // TODO: proper error handling
console.log(list[0].pm2_env.status) // print status of IGUANA proc console.log(list[0].pm2_env.status) // print status of IGUANA proc
console.log(list[0].pid) // print pid of IGUANA proc console.log(list[0].pid) // print pid of IGUANA proc
@ -130,7 +132,7 @@ shepherd.post('/getconf', function(req, res) {
//console.log(req.body.chain); //console.log(req.body.chain);
var confpath = getConf(req.body.chain); var confpath = getConf(req.body.chain);
console.log('got conf path is:') console.log('got conf path is:');
console.log(confpath); console.log(confpath);
res.end('{ "msg": "success", "result": "' + confpath + '" }'); res.end('{ "msg": "success", "result": "' + confpath + '" }');
}); });
@ -208,7 +210,7 @@ function herder(flock, data) {
}, function(err, apps) { }, function(err, apps) {
pm2.disconnect(); // Disconnect from PM2 pm2.disconnect(); // Disconnect from PM2
if (err) if (err)
throw err throw err;
}); });
}); });
} }
@ -255,7 +257,8 @@ function herder(flock, data) {
cwd: iguanaDir, cwd: iguanaDir,
}, function(err, apps) { }, function(err, apps) {
pm2.disconnect(); // Disconnect from PM2 pm2.disconnect(); // Disconnect from PM2
if (err) throw err if (err)
throw err;
}); });
}); });
} }
@ -271,6 +274,29 @@ function slayer(flock) {
}); });
} }
function saveLocalAppConf() {
var appConfFileName = iguanaDir + '/conf.json';
console.log(iguanaDir);
var fsWrite = function() {
return new Promise(function(resolve, reject) {
var result = 'write file is done'
fs.writeFile(appConfFileName, 'test', 'utf8', function(err) {
if (err)
return console.log(err);
});
fsnode.chmodSync(appConfFileName, '0666');
setTimeout(function() {
console.log(result);
resolve(result);
}, 2000);
});
}
}
function setConf(flock) { function setConf(flock) {
console.log(flock); console.log(flock);
@ -303,7 +329,7 @@ function setConf(flock) {
fs.ensureFile(DaemonConfPath, function(err) { fs.ensureFile(DaemonConfPath, function(err) {
console.log(err); // => null console.log(err); // => null
}) });
setTimeout(function() { setTimeout(function() {
console.log(result); console.log(result);

Loading…
Cancel
Save