How deploy my project?
HI, I'm new on this, and I'm try deploy my project, currently I run this with grunt serve:dist but I don't know if this is the way to deploy or if exist a better way.
I'm assuming you want to deploy your project on a dedicated server ...
Running an app with grunt serve:dist is ok, however this command line will not keep alive your app. A good way to deploy your app is to run it with a process manager.
I recommend to use PM2. This is a powerful tool that manages your processes and keep them alive. There's a whole logging and debugging kit in it.
After compiling your sources with : grunt serve:dist, you can use PM2 to launch and keep your app alive : pm2 start dist/server/index.js --name="process_name". You can add the --watch parameter if you want to automatically refresh the running app on every re-build. And that's it !
Note : I would not recommend to use sudo when running an app.
But, in my opinion, you should declare your application by creating an ecosystem.json file (example below).
pm2 ecosystem or pm2 generate will create an example file.
This file contains all the options you usually give to the pm2 start command. Therefore you'll just have to run this command every time you want to run/stop/delete your app : pm2 startOrRestart|stop|delete ecosystem.json. PM2 allows you to run more than 1 instance at a time by I won't recommend it if your projects are independent from each other.
My ecosystem.json5 file is usually like this :
{
"apps": [
{
"name": "YOUR_APP_NAME",
"script": "dist/server/index.js",
"env_production": {
"NODE_ENV": "production",
"PORT": YOUR_PORT,
},
"args": ["--release"],
"port": YOUR_PORT,
"watch": false
}
]
}
There are very good articles on the Web explaining the whole process :
- https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-14-04
- Deploying Angular Fullstack : https://github.com/angular-fullstack/generator-angular-fullstack/issues/1641
- Issues when deploying ? check here
Thanks man, that was very helpful
it works for me too, thanks.
I am using the newer version of Angular-fullstack with gulp. I ran the gulp build task that gave me a dist folder I pulled the code to my digital ocean server. Now I ran npm i peoducton but its not working any idea what to do. Irs not working. Please help