From a57c723e8aa2cdceeddb90e61e90c758029e485b Mon Sep 17 00:00:00 2001 From: Praneeth Bodduluri Date: Thu, 27 Aug 2015 20:58:15 +0530 Subject: [PATCH] Remove inotify and lint changes --- package.json | 1 - src/utils.coffee | 32 ++++++++------------------------ 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/package.json b/package.json index f4aa10f5..8a60d7bc 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,6 @@ "dockerode": "~2.2.1", "event-stream": "^3.0.20", "express": "^4.0.0", - "inotify": "^1.4.0", "knex": "~0.8.3", "lodash": "^3.0.0", "mixpanel": "0.0.20", diff --git a/src/utils.coffee b/src/utils.coffee index 6585579b..f0c02bb0 100644 --- a/src/utils.coffee +++ b/src/utils.coffee @@ -6,8 +6,6 @@ mixpanel = require 'mixpanel' networkCheck = require 'network-checker' blink = require('blinking')(config.ledFile) url = require 'url' -Inotify = require('inotify').Inotify -inotify = new Inotify() fs = Promise.promisifyAll require 'fs' utils = exports @@ -75,18 +73,9 @@ disableConnectivityCheck = false # options: An object of net.connect options, with the addition of: # timeout: 10s checkHost = (options) -> - new Promise (resolve, reject) -> - if disableConnectivityCheck - resolve() - else - if pauseConnectivityCheck - resolve() - else - reject() - .then -> + if disableConnectivityCheck or pauseConnectivityCheck return true - .catch -> - return networkCheck.checkHost(options) + return networkCheck.checkHost(options) # Custom monitor that uses checkHost function above. customMonitor = (options, fn) -> @@ -101,23 +90,18 @@ exports.disableCheck = (disable) -> disableConnectivityCheck = disable # Call back for inotify triggered when the VPN status is changed. -vpnStatusInotifyCallback = (arg) -> - fs.lstatAsync(config.vpnStatusPath+'/active') +vpnStatusInotifyCallback = -> + fs.lstatAsync(config.vpnStatusPath + '/active') .then -> - pauseConnectivityCheck=true + pauseConnectivityCheck = true .catch -> - pauseConnectivityCheck=false - -vpn_status = - path: config.vpnStatusPath - watch_for: Inotify.IN_DELETE | Inotify.IN_CREATE - callback: vpnStatusInotifyCallback + pauseConnectivityCheck = false exports.connectivityCheck = _.once -> parsedUrl = url.parse(config.apiEndpoint) - fs.mkdirAsync(vpn_status.path) + fs.mkdirAsync(config.vpnStatusPath) .then -> - inotify.addWatch(vpn_status) + fs.watch(config.vpnStatusPath, vpnStatusInotifyCallback) .catch (error) -> if error.code != 'EEXIST' throw error