Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clustering with Pm2 and HapiJS #330

Open
ThiagoMiranda opened this issue Mar 7, 2017 · 0 comments
Open

Clustering with Pm2 and HapiJS #330

ThiagoMiranda opened this issue Mar 7, 2017 · 0 comments

Comments

@ThiagoMiranda
Copy link

Hello..
I don't know if this is the right place to question these but since it's a popular repository probably someone here encounter this very issue of mine.

Basically I've turned the app into a Hapijs app using the HapiJS webpack plugin. It's a very straightforward plugin and I use it like this:

/** Register plugin and start server **/
let hapiPlugins = [{
		register: HapiSwagger,
		options: swaggerOptions
	},{
		register: Inert
	},{
		register: Vision
	},{
		register: WebpackPlugin,
		options: './webpack.config.js'
	},
	AuthCookie,
	Bell
];

let webpackPlugin = {};

/** Register plugin and start server **/
server.register(hapiPlugins);

So I've deployed my app in an ElasticBeanstalk t2.small machine using pm2 to run it:

"copy": "copyfiles -f ./src/favicon.ico ./dist"
"dist": "npm run copy & NODE_ENV=production ./node_modules/.bin/pm2 start bootstrap.js "

It's working very well ( it's a small app used internally at my company ) but I'm not sure if it's the best approach. Digging a little into pm2 I've discovered the option to cluster my application using the -i maxoption. I've putted it and it worked. But each child process built the same webpack files before launch so I have a peak on my processing and memory having, for example in my machine, 8 "webpack compile processes" running at the same time. Using pm2 I can tell which child is the master one so this is my question:

Is there any way to just run the webpack compiling process once? Basically all that I need is to get the files from the dist/folder independently of whom putted it there. Or am I doing a totally wrong approach?

Thanks for the attention,
Cheers

@ThiagoMiranda ThiagoMiranda changed the title Clustering Clustering with Pm2 Mar 7, 2017
@ThiagoMiranda ThiagoMiranda changed the title Clustering with Pm2 Clustering with Pm2 and HapiJS Mar 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant