Merge pull request #153 from resin-io/152-log-to-stdout

Log useful supervisor info to stdout/stderr
This commit is contained in:
Kostas Lekkas 2016-05-31 11:31:33 +03:00
commit bead6eb9c3
6 changed files with 23 additions and 8 deletions

View File

@ -1,3 +1,5 @@
* Log useful supervisor info to stdout/stderr [Kostas]
# v1.10.0
* Fix progress bars on docker version 1.10 [Aleksis]

View File

@ -28,4 +28,6 @@ export DBUS_SYSTEM_BUS_ADDRESS="unix:path=/mnt/root/run/dbus/system_bus_socket"
supervisorctl -c /etc/supervisor/supervisord.conf start resin-supervisor
supervisorctl -c /etc/supervisor/supervisord.conf start go-supervisor
tail -f /var/log/supervisor/supervisord.log
tail -F \
/var/log/supervisor/supervisord.log \
/var/log/resin_supervisor_stdout.log

View File

@ -30,4 +30,6 @@ export DBUS_SYSTEM_BUS_ADDRESS="unix:path=/mnt/root/run/dbus/system_bus_socket"
supervisorctl start resin-supervisor
supervisorctl start go-supervisor
tail -f /var/log/supervisor/supervisord.log
tail -F \
/var/log/supervisor/supervisord.log \
/var/log/resin_supervisor_stdout.log

View File

@ -11,11 +11,6 @@ device = require './device'
dockerUtils = require './docker-utils'
_ = require 'lodash'
privateAppEnvVars = [
'RESIN_SUPERVISOR_API_KEY'
'RESIN_API_KEY'
]
module.exports = (application) ->
api = express()
unparsedRouter = express.Router()
@ -151,7 +146,7 @@ module.exports = (application) ->
if !app?
throw new Error('App not found')
# Don't return keys on the endpoint
app.env = _.omit(JSON.parse(app.env), privateAppEnvVars)
app.env = _.omit(JSON.parse(app.env), config.privateAppEnvVars)
# Don't return data that will be of no use to the user
res.json(app)
.catch (err) ->

View File

@ -44,3 +44,7 @@ module.exports = config =
hostOsVersionPath: checkString(process.env.HOST_OS_VERSION_PATH) ? '/mnt/root/etc/os-release'
dockerRoot: dockerRoot
btrfsRoot: checkString(process.env.BTRFS_ROOT) ? "#{dockerRoot}/btrfs/subvolumes"
privateAppEnvVars: [
'RESIN_SUPERVISOR_API_KEY'
'RESIN_API_KEY'
]

View File

@ -36,6 +36,16 @@ exports.mixpanelTrack = (event, properties = {}) ->
message: properties.error.message
stack: properties.error.stack
# Don't log private env vars (e.g. api keys)
if properties?.app?.env?
try
{ env } = properties.app
env = JSON.parse(env) if _.isString(env)
safeEnv = _.omit(env, config.privateAppEnvVars)
properties.app.env = JSON.stringify(safeEnv)
catch
properties.app.env = 'Fully hidden due to error in selective hiding'
console.log('Event:', event, JSON.stringify(properties))
# Mutation is bad, and it should feel bad
properties = _.assign(_.cloneDeep(properties), mixpanelProperties)