Clean arguments transmitted to fork process
This commit is contained in:
parent
456de3414a
commit
7be9624789
2 changed files with 22 additions and 1 deletions
2
index.js
2
index.js
|
@ -31,6 +31,8 @@ if (config.title) {
|
|||
process.title = config.title;
|
||||
}
|
||||
|
||||
process.execArgv = tools.cleanArgv();
|
||||
|
||||
log.level = config.log.level;
|
||||
app.set('port', port);
|
||||
|
||||
|
|
21
lib/tools.js
21
lib/tools.js
|
@ -30,6 +30,7 @@ module.exports = {
|
|||
prepareHtml,
|
||||
purifyHTML,
|
||||
mergeTemplateIntoLayout,
|
||||
cleanArgv,
|
||||
workers: new Set()
|
||||
};
|
||||
|
||||
|
@ -211,7 +212,7 @@ function formatMessage(serviceUrl, campaign, list, subscription, message, filter
|
|||
return false;
|
||||
};
|
||||
|
||||
let tagReplace = message =>
|
||||
let tagReplace = message =>
|
||||
message.replace(/\[([a-z0-9_]+)(?:\/([^\]]+))?\]/ig, (match, identifier, fallback) => {
|
||||
identifier = identifier.toUpperCase();
|
||||
let value = getTagValue(identifier);
|
||||
|
@ -321,3 +322,21 @@ function mergeTemplateIntoLayout(template, layout, callback) {
|
|||
return done(template, layout);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function cleanArgv() {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
if (process.env.NODE_INSPECT_FORK === 'true') {
|
||||
return process.execArgv.map(opt => {
|
||||
if (opt.indexOf('--inspect') > -1 && opt.indexOf(':0') === -1) {
|
||||
const m = opt.split(/[=:]/);
|
||||
const host = m[1] && isNaN(m[1]) ? m[1] : '127.0.0.1';
|
||||
return `--inspect-brk=${host}:0`;
|
||||
}
|
||||
return opt;
|
||||
});
|
||||
}
|
||||
return process.execArgv.filter(opt => opt.indexOf('--inspect') === -1);
|
||||
}
|
||||
return process.execArgv;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue