move request to utils module
This commit is contained in:
parent
a25d225a8b
commit
08ba95576d
|
@ -1,6 +1,6 @@
|
|||
var Web3 = require('web3');
|
||||
var async = require('async');
|
||||
var request = require('request');
|
||||
var utils = require('./utils.js');
|
||||
|
||||
var ServicesMonitor = function(options) {
|
||||
this.logger = options.logger;
|
||||
|
@ -57,11 +57,11 @@ ServicesMonitor.prototype.check = function() {
|
|||
function checkIPFS(result, callback) {
|
||||
self.logger.trace('checkIPFS');
|
||||
|
||||
request('http://localhost:5001', function(error, response, body) {
|
||||
if (error) {
|
||||
result.push('IPFS'.red);
|
||||
} else {
|
||||
utils.checkIsAvailable('http://localhost:5001', function(available) {
|
||||
if (available) {
|
||||
result.push('IPFS'.green);
|
||||
} else {
|
||||
result.push('IPFS'.red);
|
||||
}
|
||||
callback(null, result);
|
||||
});
|
||||
|
|
10
lib/utils.js
10
lib/utils.js
|
@ -1,6 +1,7 @@
|
|||
var path = require('path');
|
||||
var grunt = require('grunt');
|
||||
var merge = require('merge');
|
||||
var request = require('request');
|
||||
|
||||
function joinPath() {
|
||||
return path.join.apply(path.join, arguments);
|
||||
|
@ -18,10 +19,17 @@ function recursiveMerge(target, source) {
|
|||
return merge.recursive(target, source);
|
||||
}
|
||||
|
||||
function checkIsAvailable(url, callback) {
|
||||
request(url, function(error, response, body) {
|
||||
callback(!error);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
joinPath: joinPath,
|
||||
filesMatchingPattern: filesMatchingPattern,
|
||||
fileMatchesPattern: fileMatchesPattern,
|
||||
recursiveMerge: recursiveMerge
|
||||
recursiveMerge: recursiveMerge,
|
||||
checkIsAvailable: checkIsAvailable
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue