1 | /*!
|
2 | * Copyright (c) 2012-2019 Digital Bazaar, Inc. All rights reserved.
|
3 | */
|
4 | ;
|
5 |
|
6 | // wait for initialization options from master
|
7 | process.on('message', init);
|
8 |
|
9 | // notify master to send initialization options
|
10 | process.send({type: 'bedrock.worker.started'});
|
11 |
|
12 | function init(msg) {
|
13 | if(!(typeof msg === 'object' && msg.type === 'bedrock.worker.init')) {
|
14 | return;
|
15 | }
|
16 | process.removeListener('message', init);
|
17 |
|
18 | // ensure current working directory is correct
|
19 | if(msg.cwd && process.cwd() !== msg.cwd) {
|
20 | process.chdir(msg.cwd);
|
21 | }
|
22 |
|
23 | require(msg.script);
|
24 | }
|