mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-04-16 23:38:52 +00:00
Initial commit
This commit is contained in:
commit
e1622813aa
9
app.coffee
Normal file
9
app.coffee
Normal file
@ -0,0 +1,9 @@
|
||||
chokidar = require("chokidar")
|
||||
|
||||
watcher = chokidar.watch('/media/', {ignored: /^\./, persistent: true})
|
||||
watcher.on('add', (path, stats) ->
|
||||
console.log('File', path, 'has been added')
|
||||
)
|
||||
|
||||
# Only needed if watching is persistent.
|
||||
#watcher.close()
|
2
bootstrap.js
vendored
Normal file
2
bootstrap.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
var coffee = require("coffee-script");
|
||||
var app = require("./app");
|
11
package.json
Normal file
11
package.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "bootstrap",
|
||||
"version": "0.0.1",
|
||||
"dependencies": {
|
||||
"coffee-script": "1.6.x",
|
||||
"chokidar": "0.6.x"
|
||||
},
|
||||
"engines": [
|
||||
"node >= 0.10.x"
|
||||
]
|
||||
}
|
27
util.coffee
Normal file
27
util.coffee
Normal file
@ -0,0 +1,27 @@
|
||||
fs = require("fs")
|
||||
chokidar = require("chokidar")
|
||||
#request = require("request")
|
||||
|
||||
_eol = require('os').EOL
|
||||
|
||||
getProcInfo = (callback) ->
|
||||
lines = fs.readFileSync("/proc/cpuinfo", "utf8").split(_eol)
|
||||
|
||||
cpuinfo = []
|
||||
cpuinfo.push({})
|
||||
for line in lines
|
||||
if line == ""
|
||||
cpuinfo.push({})
|
||||
else
|
||||
[key, value] = line.split(/\s+:\s/, 2)
|
||||
key = key.trim()
|
||||
value = value?.trim() ? ""
|
||||
|
||||
if value.match(/^\d+\.\d+$/)
|
||||
value = parseFloat(value)
|
||||
|
||||
cpuinfo[cpuinfo.length-1][key] = value
|
||||
|
||||
callback(cpuinfo)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user