very good concept of deploying the nodejs apps. This is exactly what we were looking for . We also wants to run app in cluster mode using PM2. so output exe file (for windows) we are taking taking and running on target system without having to install Nodejs. so how do i run the PKG app using under the PM2 cluster. Any advise ?
I've used it successfully by using the programmatic api, which requires no extra installation. That said, it is licensed under AGPL, so if that's a problem you can perhaps just use the native cluster API (it works fine as well).
But if you want to run pm2 on windows, you should install nodejs first. That's embarrassed.
I need to embeed pm2 into pkg... is posible ?
You need to use --interpreter none to run binary apps via pm2
pm2 start /path/to/bin/app --interpreter none --name "name"
@bergheim Are you saying you managed to use pkg with cluster API? My build is failing when I am using cluster
@gurisko Yes, it works fine for me. How it is failing? The cluster API is part of node itself.
@bergheim my workers are using same ports for express app which works just fine until I build them with pkg. Then all workers fail on address already in use
@gurisko use pm2 start /path/to/bin/app --interpreter none --name "name" --instances 1
to start just one instance
you can run : pm2 start ./bin (bin is your app that built with pkg )
you can run : pm2 start ./bin (bin is your app that built with pkg )
thank you, this is what I looking for 馃榿
What about just creating a standard service on the OS to run your packaged application?
Ubuntu Example: https://wiki.debian.org/systemd/Services
Windows Example: https://support.microsoft.com/en-us/help/251192/how-to-create-a-windows-service-by-using-sc-exe
@bergheim how did you use the programmatic api to embeed pm2 in pkg? I am trying to embeed pm2 in pkg and run it as an executable file in a windows machine
I removed it 2 years ago for the native cluster module (because of the AGPL license PM2 comes with), but basically https://pm2.keymetrics.io/docs/usage/pm2-api/ explained how to do it. Any specific problems?
After embedding pm2 in pkg, when I start the server pm2 was dying with had too many unstable restarts (16). Stopped. "errored"
@frytaz I believe that
--instances 1
is not what we want to achieve with cluster mode.
Most helpful comment
you can run : pm2 start ./bin (bin is your app that built with pkg )