Comparing version 4.2.0 to 4.2.1
# bedrock ChangeLog | ||
## 4.2.1 - 2021-07-01 | ||
## Changed | ||
- Replace 'master' language in process, config, and logging to use 'primary'. | ||
- Backwards compatibility for `config.core.master` (removal planned for 5.x). | ||
## 4.2.0 - 2021-06-30 | ||
@@ -4,0 +10,0 @@ |
@@ -135,4 +135,4 @@ /*! | ||
if(cluster.isMaster) { | ||
_runMaster(startTime, options); | ||
// don't call callback in master process | ||
_runPrimary(startTime, options); | ||
// don't call callback in primary process | ||
return; | ||
@@ -149,3 +149,3 @@ } | ||
/** | ||
* Called from workers to set the worker and master process user if it hasn't | ||
* Called from workers to set the worker and primary process user if it hasn't | ||
* already been set. | ||
@@ -167,3 +167,3 @@ */ | ||
} | ||
// send message to master | ||
// send message to primary | ||
process.send({type: 'bedrock.switchProcessUser'}); | ||
@@ -187,3 +187,3 @@ }; | ||
// notify master to schedule work (if not already scheduled/run) | ||
// notify primary to schedule work (if not already scheduled/run) | ||
process.send({type, id, options}); | ||
@@ -234,3 +234,3 @@ | ||
async function _waitForOneMessage({type, id}) { | ||
// get coordinated message from master | ||
// get coordinated message from primary | ||
return new Promise(resolve => { | ||
@@ -351,3 +351,3 @@ // listen to run function once | ||
} catch(ex) { | ||
console.warn('Failed to set master starting gid: ' + ex); | ||
console.warn('Failed to set primary starting gid: ' + ex); | ||
} | ||
@@ -360,3 +360,3 @@ } | ||
} catch(ex) { | ||
console.warn('Failed to set master starting uid: ' + ex); | ||
console.warn('Failed to set primary starting uid: ' + ex); | ||
} | ||
@@ -409,6 +409,6 @@ } | ||
function _runMaster(startTime, options) { | ||
function _runPrimary(startTime, options) { | ||
// FIXME: use child logger | ||
const logger = loggers.get('app'); | ||
const logPrefix = '[bedrock/master]'; | ||
const logPrefix = '[bedrock/primary]'; | ||
@@ -429,3 +429,6 @@ // setup cluster if running with istanbul coverage | ||
const args = process.argv.slice(2).join(' '); | ||
process.title = config.core.master.title + (args ? (' ' + args) : ''); | ||
// TODO: Remove all use of config.core.master in next major release (5.x) | ||
const processTitle = config.core.master ? | ||
config.core.master.title : config.core.primary.title; | ||
process.title = processTitle + (args ? (' ' + args) : ''); | ||
@@ -436,3 +439,3 @@ _setupUncaughtExceptionHandler(logger, logPrefix); | ||
logger.info( | ||
`${logPrefix} starting process "${config.core.master.title}"`, | ||
`${logPrefix} starting process "${processTitle}"`, | ||
{pid: process.pid}); | ||
@@ -443,4 +446,4 @@ | ||
// keep track of master state | ||
const masterState = { | ||
// keep track of primary state | ||
const primaryState = { | ||
switchedUser: false, | ||
@@ -450,3 +453,3 @@ runOnce: {} | ||
// notify workers to exit if master exits | ||
// notify workers to exit if primary exits | ||
process.on('exit', function() { | ||
@@ -465,3 +468,3 @@ for(const id in cluster.workers) { | ||
`${logPrefix} worker "${worker.process.pid}" exited on purpose ` + | ||
`with code "${code}" and signal "${signal}"; exiting master process.`); | ||
`with code "${code}" and signal "${signal}"; exiting primary process.`); | ||
process.exit(code); | ||
@@ -478,9 +481,9 @@ } | ||
// clear any runOnce records w/allowOnRestart option set | ||
for(const id in masterState.runOnce) { | ||
if(masterState.runOnce[id].worker === worker.id && | ||
masterState.runOnce[id].options.allowOnRestart) { | ||
delete masterState.runOnce[id]; | ||
for(const id in primaryState.runOnce) { | ||
if(primaryState.runOnce[id].worker === worker.id && | ||
primaryState.runOnce[id].options.allowOnRestart) { | ||
delete primaryState.runOnce[id]; | ||
} | ||
} | ||
_startWorker(masterState, script); | ||
_startWorker(primaryState, script); | ||
} else { | ||
@@ -494,3 +497,3 @@ process.exit(1); | ||
for(let i = 0; i < workers; ++i) { | ||
_startWorker(masterState, script); | ||
_startWorker(primaryState, script); | ||
} | ||
@@ -514,3 +517,3 @@ logger.info(`${logPrefix} started`, {timeMs: Date.now() - startTime}); | ||
// listen for master process exit | ||
// listen for primary process exit | ||
let bedrockStarted = false; | ||
@@ -517,0 +520,0 @@ process.on('message', function(msg) { |
@@ -28,3 +28,3 @@ /*! | ||
// master process while starting | ||
// primary process while starting | ||
config.core.starting = {}; | ||
@@ -35,3 +35,3 @@ // in production may want to use 'adm' group | ||
// master and workers after starting | ||
// primary and workers after starting | ||
config.core.running = {}; | ||
@@ -41,5 +41,7 @@ config.core.running.groupId = null; | ||
// master process | ||
// primary process | ||
config.core.primary = {}; | ||
config.core.primary.title = 'bedrock1d'; | ||
// TODO: Remove in next major release (5.x) | ||
config.core.master = {}; | ||
config.core.master.title = 'bedrock1d'; | ||
@@ -46,0 +48,0 @@ // worker processes |
@@ -50,3 +50,3 @@ /*! | ||
// create the container for the master and all of the workers | ||
// create the container for the primary and all of the workers | ||
const container = new winston.Container(); | ||
@@ -194,3 +194,3 @@ // override get to use a wrapper so loggers that are retrieved via `.get()` | ||
// create master loggers | ||
// create primary loggers | ||
for(const cat in config.loggers.categories) { | ||
@@ -218,3 +218,3 @@ const transportNames = config.loggers.categories[cat]; | ||
* Attaches a message handler to the given worker. This should be | ||
* called by the master process to handle worker log messages. | ||
* called by the primary process to handle worker log messages. | ||
* | ||
@@ -224,3 +224,3 @@ * @param worker the worker to attach the message handler to. | ||
container.attach = function(worker) { | ||
// set up message handler for master process | ||
// set up message handler for primary process | ||
worker.on('message', function(msg) { | ||
@@ -261,3 +261,3 @@ if(typeof msg === 'object' && msg.type === 'bedrock.logger') { | ||
* Adds a new transport. This must be called prior to `container.init` and | ||
* is a noop if the current process is not the master process. | ||
* is a noop if the current process is not the primary process. | ||
* | ||
@@ -264,0 +264,0 @@ * @param name the name of the transport to add; if a name has already been |
@@ -35,3 +35,3 @@ /*! | ||
// send logger message to master | ||
// send logger message to primary | ||
process.send({ | ||
@@ -38,0 +38,0 @@ type: 'bedrock.logger', |
@@ -6,6 +6,6 @@ /*! | ||
// wait for initialization options from master | ||
// wait for initialization options from primary | ||
process.on('message', init); | ||
// notify master to send initialization options | ||
// notify primary to send initialization options | ||
process.send({type: 'bedrock.worker.started'}); | ||
@@ -12,0 +12,0 @@ |
{ | ||
"name": "bedrock", | ||
"version": "4.2.0", | ||
"version": "4.2.1", | ||
"description": "A core foundation for rich Web applications.", | ||
@@ -5,0 +5,0 @@ "license": "SEE LICENSE IN LICENSE.md", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
151816
2292