mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-19 13:47:54 +00:00
Change to use 204 for API, Remove extra space in upscript.sh and Make fswatch start only on EEXIST error
This commit is contained in:
parent
7b8ca9fd73
commit
a8e1d476e3
@ -9,7 +9,7 @@ bodyParser = require 'body-parser'
|
||||
request = require 'request'
|
||||
config = require './config'
|
||||
|
||||
module.exports = (secret, disableCheck) ->
|
||||
module.exports = (secret) ->
|
||||
api = express()
|
||||
api.use(bodyParser())
|
||||
api.use (req, res, next) ->
|
||||
@ -85,11 +85,11 @@ module.exports = (secret, disableCheck) ->
|
||||
res.status(503).send(err?.message or err or 'Unknown error')
|
||||
|
||||
api.post '/tcp-ping', (req, res) ->
|
||||
disableCheck(false)
|
||||
res.status(200).send('OK\n')
|
||||
utils.disableCheck(false)
|
||||
res.sendStatus(204)
|
||||
|
||||
api.delete '/tcp-ping', (req, res) ->
|
||||
disableCheck(true)
|
||||
res.status(200).send('OK\n')
|
||||
utils.disableCheck(true)
|
||||
res.sendStatus(204)
|
||||
|
||||
return api
|
||||
|
@ -37,7 +37,7 @@ knex.init.then ->
|
||||
console.log('Starting API server..')
|
||||
|
||||
secret = config.forceApiSecret ? randomstring.generate()
|
||||
api(secret, utils.disableCheck).listen(config.listenPort)
|
||||
api(secret).listen(config.listenPort)
|
||||
|
||||
# Let API know what version we are, and our api connection info.
|
||||
console.log('Updating supervisor version and api info')
|
||||
|
@ -103,11 +103,10 @@ EEXIST = (err) -> err.code is 'EEXIST'
|
||||
exports.connectivityCheck = _.once ->
|
||||
parsedUrl = url.parse(config.apiEndpoint)
|
||||
fs.mkdirAsync(config.vpnStatusPath)
|
||||
.then ->
|
||||
console.log('Creating directory for watching VPN status...')
|
||||
.finally ->
|
||||
fs.watch(config.vpnStatusPath, vpnStatusInotifyCallback)
|
||||
.catch EEXIST, (err) ->
|
||||
console.log('VPN status path exists.')
|
||||
.then ->
|
||||
fs.watch(config.vpnStatusPath, vpnStatusInotifyCallback)
|
||||
|
||||
# Manually trigger the call back to detect cases when VPN was switched on before the supervisor starts.
|
||||
vpnStatusInotifyCallback()
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
mkdir -p /run/openvpn/vpn_status
|
||||
touch /run/openvpn/vpn_status/active
|
||||
touch /run/openvpn/vpn_status/active
|
||||
|
Loading…
Reference in New Issue
Block a user