mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-01-29 15:44:13 +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) ->
|
||||
fs.writeFileAsync(LED_FILE, 1)
|
||||
.then(-> utils.delay(ms))
|
||||
.then(-> fs.writeFileAsync(LED_FILE, 0))
|
||||
.then -> utils.delay(ms)
|
||||
.then -> fs.writeFileAsync(LED_FILE, 0)
|
||||
|
||||
api.post('/v1/blink', (req, res) ->
|
||||
api.post '/v1/blink', (req, res) ->
|
||||
interval = setInterval(blink, 400)
|
||||
setTimeout(->
|
||||
clearInterval(interval)
|
||||
, 5000)
|
||||
res.send(200)
|
||||
)
|
||||
|
||||
api.post('/v1/update', (req, res) ->
|
||||
api.post '/v1/update', (req, res) ->
|
||||
console.log("Got application update")
|
||||
application.update()
|
||||
res.send(204)
|
||||
)
|
||||
|
||||
module.exports = api
|
||||
|
@ -14,42 +14,40 @@ console.log('Supervisor started..')
|
||||
newUuid = utils.getDeviceUuid()
|
||||
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
|
||||
if newUuid is oldUuid
|
||||
return true
|
||||
|
||||
console.log('New device detected. Bootstrapping..')
|
||||
return bootstrap(newUuid)
|
||||
).then(->
|
||||
.then ->
|
||||
console.log('Starting OpenVPN..')
|
||||
openvpn = spawn('openvpn', ['client.conf'], cwd: '/supervisor/data')
|
||||
|
||||
# Prefix and log all OpenVPN output
|
||||
openvpn.stdout.on('data', (data) ->
|
||||
openvpn.stdout.on 'data', (data) ->
|
||||
prefix = 'OPENVPN: '
|
||||
console.log((prefix + data).trim().replace(/\n/gm, "\n#{prefix}"))
|
||||
)
|
||||
|
||||
# Prefix and log all OpenVPN output
|
||||
openvpn.stderr.on('data', (data) ->
|
||||
openvpn.stderr.on 'data', (data) ->
|
||||
prefix = 'OPENVPN: '
|
||||
console.log((prefix + data).trim().replace(/\n/gm, "\n#{prefix}"))
|
||||
)
|
||||
|
||||
console.log('Starting API server..')
|
||||
api.listen(80)
|
||||
|
||||
console.log('Starting Apps..')
|
||||
knex('app').select().then((apps) ->
|
||||
knex('app').select()
|
||||
.then (apps) ->
|
||||
Promise.all(apps.map((app) -> app.imageId).map(application.restart))
|
||||
).catch((error) ->
|
||||
.catch (error) ->
|
||||
console.error("Error starting apps:", error)
|
||||
).then(->
|
||||
.then ->
|
||||
console.log('Starting periodic check for updates..')
|
||||
setInterval(->
|
||||
application.update()
|
||||
, 15 * 60 * 1000) # Every 15 mins
|
||||
application.update()
|
||||
)
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user