Commit e8f99859 authored by priit's avatar priit

Teenuse install url-lt

parent f34d0281
...@@ -10,6 +10,16 @@ router.get('/config', function(req, res) { ...@@ -10,6 +10,16 @@ router.get('/config', function(req, res) {
return res.send(installService.getConfiguration()); return res.send(installService.getConfiguration());
}); });
router.get('/install', function(req, res) {
installService.install(function (err, success) {
if(err){
res.status(520);
res.send({errors: err});
return;
}
res.send({responses: success});
});
});
router.post('/', function ( req, res ) { router.post('/', function ( req, res ) {
......
...@@ -12,6 +12,12 @@ var InstallService = function() { ...@@ -12,6 +12,12 @@ var InstallService = function() {
var wrapper = config.wrapper; var wrapper = config.wrapper;
var serviceConfig = self.getConfiguration(); var serviceConfig = self.getConfiguration();
if(!config.integration || config.integration.length == 0){
return cb('Servereid ei ole seadistatud');
}
var messages = [];
async.each(config.integration, function (serverConf, innerCb) { async.each(config.integration, function (serverConf, innerCb) {
logger.debug(serverConf); logger.debug(serverConf);
...@@ -22,18 +28,23 @@ var InstallService = function() { ...@@ -22,18 +28,23 @@ var InstallService = function() {
json: serviceConfig json: serviceConfig
}, function(error, response, body) { }, function(error, response, body) {
if(error){ if(error){
logger.error( serverConf.installUrl); logger.error( serverConf.installUrl );
logger.error(self.getConfiguration()); logger.error( self.getConfiguration() );
logger.error(error); logger.error(error);
return innerCb(error); return innerCb(error);
} }
innerCb(null, true);
messages.push({
url: serverConf.installUrl,
response: body
});
innerCb(null);
}); });
}, function (err) { }, function (err) {
logger.debug('Installed'); logger.debug('Installed');
cb(err, true) cb(err, messages)
}); });
}; };
......
...@@ -77,13 +77,6 @@ function startCluster( instanceCount, cb ){ ...@@ -77,13 +77,6 @@ function startCluster( instanceCount, cb ){
cleanerService.init(); cleanerService.init();
//Lase serveril üles ärgata
setTimeout(function(){
installService.install(function () {
log4jsLogger.trace('Instal callback');
})
}, ((Math.random() * 20000) + 5000 ));
} else { } else {
startInstance(cb) startInstance(cb)
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment