Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Can I run PM2 with Angular-Cli? - Angular2

How can I run: ng serve --prod with pm2?

ng serve from angular-cli, Angular2. I'm running on DigitalOcean.

I have tried to test with http-server -p 4200 -d false in the dist/ folder after ng build --prod

When I request from the domain https://www.unibookkh.com/, i got 404 error: (I've already setup nginx to listen to port 4200.

enter image description here

I test with http-server because I think I maybe can run pm2 through this command pm2 start my_app_process.json where

my_app_process.json

{
    "apps": [
        {
            "name": "angular",
            "cwd": "~/angular2",
            "args": "-p 4200 -d false",
            "script": "/usr/bin/http-server"
        }
    ]
}

Any better ideas of how to get it working with PM2?

like image 885
Vicheanak Avatar asked Sep 04 '16 07:09

Vicheanak


People also ask

What is PM2 in angular?

PM2 is a production process manager for Node. js applications with a built-in load balancer. It allows you to keep applications alive forever, to reload them without downtime and to facilitate common system admin tasks.


1 Answers

This command would work as expected:

after I run

ng build --prod

then run the following command in the dist/ folder

pm2 start /usr/bin/http-server -- -p 8080 -d false

Update

I have found a better solution: which ng then it will print /usr/bin/ng then type this

pm2 start /usr/bin/ng -- serve --prod

like image 62
Vicheanak Avatar answered Oct 02 '22 16:10

Vicheanak