mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-21 22:47:49 +00:00
Remove inotify and lint changes
This commit is contained in:
parent
a4966a798a
commit
a57c723e8a
@ -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",
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user