mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-02-11 13:35:28 +00:00
Remove some more unnecessary parens.
This commit is contained in:
parent
e8e6490dd2
commit
b65e3fd3f9
@ -10,21 +10,19 @@ LED_FILE = '/sys/class/leds/led0/brightness'
|
|||||||
|
|
||||||
blink = (ms = 200) ->
|
blink = (ms = 200) ->
|
||||||
fs.writeFileAsync(LED_FILE, 1)
|
fs.writeFileAsync(LED_FILE, 1)
|
||||||
.then(-> utils.delay(ms))
|
.then -> utils.delay(ms)
|
||||||
.then(-> fs.writeFileAsync(LED_FILE, 0))
|
.then -> fs.writeFileAsync(LED_FILE, 0)
|
||||||
|
|
||||||
api.post('/v1/blink', (req, res) ->
|
api.post '/v1/blink', (req, res) ->
|
||||||
interval = setInterval(blink, 400)
|
interval = setInterval(blink, 400)
|
||||||
setTimeout(->
|
setTimeout(->
|
||||||
clearInterval(interval)
|
clearInterval(interval)
|
||||||
, 5000)
|
, 5000)
|
||||||
res.send(200)
|
res.send(200)
|
||||||
)
|
|
||||||
|
|
||||||
api.post('/v1/update', (req, res) ->
|
api.post '/v1/update', (req, res) ->
|
||||||
console.log("Got application update")
|
console.log("Got application update")
|
||||||
application.update()
|
application.update()
|
||||||
res.send(204)
|
res.send(204)
|
||||||
)
|
|
||||||
|
|
||||||
module.exports = api
|
module.exports = api
|
||||||
|
@ -14,42 +14,40 @@ console.log('Supervisor started..')
|
|||||||
newUuid = utils.getDeviceUuid()
|
newUuid = utils.getDeviceUuid()
|
||||||
oldUuid = knex('config').select('value').where(key: 'uuid')
|
oldUuid = knex('config').select('value').where(key: 'uuid')
|
||||||
|
|
||||||
Promise.all([newUuid, oldUuid]).then(([newUuid, [oldUuid]]) ->
|
Promise.all([newUuid, oldUuid])
|
||||||
|
.then ([newUuid, [oldUuid]]) ->
|
||||||
oldUuid = oldUuid?.value
|
oldUuid = oldUuid?.value
|
||||||
if newUuid is oldUuid
|
if newUuid is oldUuid
|
||||||
return true
|
return true
|
||||||
|
|
||||||
console.log('New device detected. Bootstrapping..')
|
console.log('New device detected. Bootstrapping..')
|
||||||
return bootstrap(newUuid)
|
return bootstrap(newUuid)
|
||||||
).then(->
|
.then ->
|
||||||
console.log('Starting OpenVPN..')
|
console.log('Starting OpenVPN..')
|
||||||
openvpn = spawn('openvpn', ['client.conf'], cwd: '/supervisor/data')
|
openvpn = spawn('openvpn', ['client.conf'], cwd: '/supervisor/data')
|
||||||
|
|
||||||
# Prefix and log all OpenVPN output
|
# Prefix and log all OpenVPN output
|
||||||
openvpn.stdout.on('data', (data) ->
|
openvpn.stdout.on 'data', (data) ->
|
||||||
prefix = 'OPENVPN: '
|
prefix = 'OPENVPN: '
|
||||||
console.log((prefix + data).trim().replace(/\n/gm, "\n#{prefix}"))
|
console.log((prefix + data).trim().replace(/\n/gm, "\n#{prefix}"))
|
||||||
)
|
|
||||||
|
|
||||||
# Prefix and log all OpenVPN output
|
# Prefix and log all OpenVPN output
|
||||||
openvpn.stderr.on('data', (data) ->
|
openvpn.stderr.on 'data', (data) ->
|
||||||
prefix = 'OPENVPN: '
|
prefix = 'OPENVPN: '
|
||||||
console.log((prefix + data).trim().replace(/\n/gm, "\n#{prefix}"))
|
console.log((prefix + data).trim().replace(/\n/gm, "\n#{prefix}"))
|
||||||
)
|
|
||||||
|
|
||||||
console.log('Starting API server..')
|
console.log('Starting API server..')
|
||||||
api.listen(80)
|
api.listen(80)
|
||||||
|
|
||||||
console.log('Starting Apps..')
|
console.log('Starting Apps..')
|
||||||
knex('app').select().then((apps) ->
|
knex('app').select()
|
||||||
|
.then (apps) ->
|
||||||
Promise.all(apps.map((app) -> app.imageId).map(application.restart))
|
Promise.all(apps.map((app) -> app.imageId).map(application.restart))
|
||||||
).catch((error) ->
|
.catch (error) ->
|
||||||
console.error("Error starting apps:", error)
|
console.error("Error starting apps:", error)
|
||||||
).then(->
|
.then ->
|
||||||
console.log('Starting periodic check for updates..')
|
console.log('Starting periodic check for updates..')
|
||||||
setInterval(->
|
setInterval(->
|
||||||
application.update()
|
application.update()
|
||||||
, 15 * 60 * 1000) # Every 15 mins
|
, 15 * 60 * 1000) # Every 15 mins
|
||||||
application.update()
|
application.update()
|
||||||
)
|
|
||||||
)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user