How would I start a pm2
process with the —max-http-header-size
node option, as well as name the process.
I have a server with multiple micro-services, one of the services is a web scraper.
This web scraper accepts requests with headers over the nodejs
default 8kb
limit. So, to run my app locally have to add the --max-http-header-size
node option.
I've cloned my app to the server, but don't know how to set --max-http-header-size
, nor do I know how to name the process within the pm2 start
command.
So far my attempts have looked like this.
// this sets the name, but I don't know how to add the option `--max-http-header-size`
pm2 start npm --name "{REPONAME}" -- start
pm2 start node --name "scraper" --max-http-header-size 15000 app.js
pm2 start node --max-http-header-size 15000 app.js -- --name "scraper"
CodePudding user response:
What you're looking for is called environment variables! You can pass environment variables to pm2 using a file that loads your server like this:
module.exports = {
apps : [
{
name: "myapp",
script: "./app.js",
watch: true,
env: {
"max-http-header-size": "15000",
}
}
]
}
Here's more about it too: https://pm2.keymetrics.io/docs/usage/environment/