mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-23 15:32:24 +00:00
Change the EEXIST to a function
This commit is contained in:
parent
a57c723e8a
commit
ac545ccc52
@ -6,7 +6,6 @@ mixpanel = require 'mixpanel'
|
|||||||
networkCheck = require 'network-checker'
|
networkCheck = require 'network-checker'
|
||||||
blink = require('blinking')(config.ledFile)
|
blink = require('blinking')(config.ledFile)
|
||||||
url = require 'url'
|
url = require 'url'
|
||||||
fs = Promise.promisifyAll require 'fs'
|
|
||||||
|
|
||||||
utils = exports
|
utils = exports
|
||||||
|
|
||||||
@ -97,14 +96,16 @@ vpnStatusInotifyCallback = ->
|
|||||||
.catch ->
|
.catch ->
|
||||||
pauseConnectivityCheck = false
|
pauseConnectivityCheck = false
|
||||||
|
|
||||||
|
# Use the following to catch EEXIST errors
|
||||||
|
EEXIST = (err) -> err.code is 'EEXIST'
|
||||||
|
|
||||||
exports.connectivityCheck = _.once ->
|
exports.connectivityCheck = _.once ->
|
||||||
parsedUrl = url.parse(config.apiEndpoint)
|
parsedUrl = url.parse(config.apiEndpoint)
|
||||||
fs.mkdirAsync(config.vpnStatusPath)
|
fs.mkdirAsync(config.vpnStatusPath)
|
||||||
.then ->
|
.then ->
|
||||||
fs.watch(config.vpnStatusPath, vpnStatusInotifyCallback)
|
fs.watch(config.vpnStatusPath, vpnStatusInotifyCallback)
|
||||||
.catch (error) ->
|
.catch EEXIST, (err) ->
|
||||||
if error.code != 'EEXIST'
|
|
||||||
throw error
|
|
||||||
# Manually trigger the call back to detect cases when VPN was switched on before the supervisor starts.
|
# Manually trigger the call back to detect cases when VPN was switched on before the supervisor starts.
|
||||||
vpnStatusInotifyCallback()
|
vpnStatusInotifyCallback()
|
||||||
customMonitor
|
customMonitor
|
||||||
|
Loading…
Reference in New Issue
Block a user