containership.plugin.logs
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -5,5 +5,5 @@ 'use strict'; | ||
const _ = require('lodash'); | ||
const ContainershipPlugin = require('containership.plugin'); | ||
const APPLICATION_NAME = 'containership-logs'; | ||
@@ -13,14 +13,15 @@ module.exports = new ContainershipPlugin({ | ||
initialize: function(core) { | ||
const DEFAULT_LOG_PATH = core.options['base-log-dir'] || '/var/log/containership'; | ||
const application_name = 'containership-logs'; | ||
core.logger.register(application_name); | ||
runFollower: (core) => { | ||
core.loggers[APPLICATION_NAME].log('verbose', `${APPLICATION_NAME} does not run on follower nodes.`); | ||
}, | ||
runLeader: (core) => { | ||
const add_application = () => { | ||
const DEFAULT_LOG_PATH = core.options['base-log-dir'] || '/var/log/containership'; | ||
core.cluster.myriad.persistence.get( | ||
[core.constants.myriad.APPLICATION_PREFIX, application_name].join(core.constants.myriad.DELIMITER), | ||
[core.constants.myriad.APPLICATION_PREFIX, APPLICATION_NAME].join(core.constants.myriad.DELIMITER), | ||
(err) => { | ||
if(err) { | ||
return core.applications.add({ | ||
id: application_name, | ||
id: APPLICATION_NAME, | ||
image: 'containership/docker-cs-logs:latest', | ||
@@ -35,3 +36,3 @@ cpus: 0.1, | ||
metadata: { | ||
plugin: application_name, | ||
plugin: APPLICATION_NAME, | ||
ancestry: 'containership.plugin' | ||
@@ -50,7 +51,7 @@ } | ||
}, () => { | ||
core.loggers[application_name].log('verbose', ['Created ', application_name, '!'].join('')); | ||
core.loggers[APPLICATION_NAME].log('verbose', `Created ${APPLICATION_NAME}!`); | ||
}); | ||
} | ||
return core.loggers[application_name].log('verbose', [application_name, 'already exists, skipping create!'].join(' ')); | ||
return core.loggers[APPLICATION_NAME].log('verbose', `${APPLICATION_NAME} already exists, skipping create!`); | ||
} | ||
@@ -60,19 +61,21 @@ ); | ||
if('leader' === core.options.mode) { | ||
if(core.cluster.praetor.is_controlling_leader()) { | ||
add_application(); | ||
} | ||
if(core.cluster.praetor.is_controlling_leader()) { | ||
add_application(); | ||
} | ||
core.cluster.legiond.on('promoted', () => { | ||
core.cluster.myriad.persistence.keys(core.constants.myriad.APPLICATIONS, (err, applications) => { | ||
if(err || !_.isEmpty(applications)) { | ||
return add_application(); | ||
} | ||
core.cluster.legiond.on('myriad.bootstrapped', () => { | ||
add_application(); | ||
}); | ||
return setTimeout(add_application, 2000); | ||
}); | ||
}); | ||
return logs.Init(core).register_routes(); | ||
}, | ||
return logs.Init(core).register_routes(); | ||
initialize: function(core) { | ||
core.logger.register(APPLICATION_NAME); | ||
if(core.options.mode === 'leader') { | ||
return module.exports.runLeader(core); | ||
} | ||
return module.exports.runFollower(core); | ||
}, | ||
@@ -79,0 +82,0 @@ |
@@ -113,2 +113,3 @@ 'use strict'; | ||
res.header('Connection', 'keep-alive'); | ||
res.header('X-Accel-Buffering', 'no'); | ||
res.status(200); | ||
@@ -115,0 +116,0 @@ |
{ | ||
"name": "containership.plugin.logs", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"dependencies": { | ||
@@ -5,0 +5,0 @@ "acorn": { |
{ | ||
"name": "containership.plugin.logs", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "Official logging plugin for ContainerShip", | ||
@@ -5,0 +5,0 @@ "main": "application.js", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
1033
1
75981