mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-06-01 23:30:48 +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'
|
request = require 'request'
|
||||||
config = require './config'
|
config = require './config'
|
||||||
|
|
||||||
module.exports = (secret, disableCheck) ->
|
module.exports = (secret) ->
|
||||||
api = express()
|
api = express()
|
||||||
api.use(bodyParser())
|
api.use(bodyParser())
|
||||||
api.use (req, res, next) ->
|
api.use (req, res, next) ->
|
||||||
@ -85,11 +85,11 @@ module.exports = (secret, disableCheck) ->
|
|||||||
res.status(503).send(err?.message or err or 'Unknown error')
|
res.status(503).send(err?.message or err or 'Unknown error')
|
||||||
|
|
||||||
api.post '/tcp-ping', (req, res) ->
|
api.post '/tcp-ping', (req, res) ->
|
||||||
disableCheck(false)
|
utils.disableCheck(false)
|
||||||
res.status(200).send('OK\n')
|
res.sendStatus(204)
|
||||||
|
|
||||||
api.delete '/tcp-ping', (req, res) ->
|
api.delete '/tcp-ping', (req, res) ->
|
||||||
disableCheck(true)
|
utils.disableCheck(true)
|
||||||
res.status(200).send('OK\n')
|
res.sendStatus(204)
|
||||||
|
|
||||||
return api
|
return api
|
||||||
|
@ -37,7 +37,7 @@ knex.init.then ->
|
|||||||
console.log('Starting API server..')
|
console.log('Starting API server..')
|
||||||
|
|
||||||
secret = config.forceApiSecret ? randomstring.generate()
|
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.
|
# Let API know what version we are, and our api connection info.
|
||||||
console.log('Updating supervisor version and api info')
|
console.log('Updating supervisor version and api info')
|
||||||
|
@ -103,11 +103,10 @@ 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 ->
|
|
||||||
console.log('Creating directory for watching VPN status...')
|
|
||||||
.finally ->
|
|
||||||
fs.watch(config.vpnStatusPath, vpnStatusInotifyCallback)
|
|
||||||
.catch EEXIST, (err) ->
|
.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.
|
# Manually trigger the call back to detect cases when VPN was switched on before the supervisor starts.
|
||||||
vpnStatusInotifyCallback()
|
vpnStatusInotifyCallback()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
mkdir -p /run/openvpn/vpn_status
|
mkdir -p /run/openvpn/vpn_status
|
||||||
touch /run/openvpn/vpn_status/active
|
touch /run/openvpn/vpn_status/active
|
||||||
|
Loading…
x
Reference in New Issue
Block a user