You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 29, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Jul 29, 2026. It is now read-only.
@JaKXz for now my deployment strategy is mainly using git.
Just code as you always do and when you need to deploy go into de server, do a pull to a specific commit (the production branch) and then start testing, if something goes wrong then you can make a rollback to a specific commit that used to work.
Of course this is the manual process, an automated process should be a script or command line tool that logins to your amazon ec2 instance, navigate to the folder, make a backup, pull latest changes.
And also receive a command that can make a rollback (get into server, navigate to folder, put back the backup).
I was missing the command that kept the application, after some time googling i found that this:
nohup grunt serve:dist --force &
works quite well. The --force param is needed because there is no desktop environment (because is a server) and prevents from failing at the very end. nohup is for no hangup and the & is for running in background.
If you still don't recover the control of the command line just press enter, it should do the trick.
I haven no ec2/node experience (yet,) but this article describes a method using forever, which is a nice node module for keeping your app alive. There is another one here and more by googling "ec2 node forever"
You won't launch the server with grunt this way. You should only be using grunt to launch your server for development. In production, grunt will just get in the way..
But, I believe this is the core command you'd need:
cd /path/to/server/folder/ && forever start app.js
Let me know if that helps. If not, I might try setting up an ec2 instance myself and see if I can't get the demo project running on it.
P.S You'll need to install forever globally first: npm install -g forever
@mescalito there's a lot of really useful stuff in your recipe.
One possible issue - if you are binding the NODE_ENV setting to when git commits from the client (which stops and restarts forever process manager), what happens if the server restarts for a different reason? Presumably the production env would not get passed...
@victorhugoviiii That's because any running process will close once you close a terminal session. Using something like nohup node server/app > log should work.
thanks @mescalito I used most of your recipe to deploy on AWS EC2 . I also got a mongo DB working
I'll share a couple things that I worked through :
I couldn't figure out how to push a single directory (dist) from within an existing git repo(I do want to track my entire project) into the new distrepo . I opted for cutting and pasting the dist files into the separate distrepo I tried all sorts of git subtree stuff but finally decided copying and replacing all wouldn't be much a burden.
on a mac that "puttykeyfile" or any other names I guessed didn't work. I worked around it using first two lines mescalito put in his gitconfig file and then I easily set a ssh on my mac like this: ssh-add /Users/tomn/documents/projects/awskeystorage/ThisProjectPair.pem
I used @wmyers suggested link and setup bash to set the NODE_ENV to production: $ echo export NODE_ENV=production >> ~/.bash_profile $ source ~/.bash_profile
it just seemed more straightforward and more useful in other cases of server shutdown than the .sh file
IF you followed 3 and set NODE_ENV to production you'll avoid npm install intalling all of dev dependencies avoiding much of - Dependencies unmet: I had hundreds of warnings I believe due to my initial attempts to compile via grunt instead of using the mescalitos technique of pushing dist.
Note 2: AWS ec2 instances evidently go awry with some frequency. I spoke to a AWS support person at their pop-up loft in SF and he advised me that a very very early thing to try when things start working is to launch a new EC2 instance and try your code on that before assuming your code is at fault. "is the cord plugged in" debugging almost. I wasted a couple weeks looking for issues with my passport-facebook and passport-twitter ouath which went away after I launched a new ec2 instance.
I know this issue is quite old now and there has been some good input already on deploying to AWS, but in case anyone is interested, here's a guide I put together for my team detailing the steps needed to take an Angular Fullstack app from development to production using AWS OpsWorks.
I know this differs from Heroku/Openshift deployment in that it doesn't push directly to your production servers, but I'm a huge fan of OpsWorks and since I started using it a year or so ago, I haven't looked back.
The biggest advantage for me is it gives Devs and QA testers the power to launch a new instance with a couple of clicks and have their server up-and-running with the latest tagged version of the app in a couple of minutes.
Reacted by bogini, genius-hub, Simon Victory, Adam Wamai Egesa and joserhond
Activity
JaKXz commentedon Aug 31, 2014
I would find this useful too. @nschurmann would you happen to have an implementation you could put into a PR?
nschurmann commentedon Sep 2, 2014
@JaKXz i don't have an implementation, actually i'm trying to deploy the app into a debian server without any success.
remicastaing commentedon Sep 2, 2014
Have you take a look at this: https://github.com/bevacqua/grunt-ec2?
nschurmann commentedon Sep 2, 2014
@remicastaing looks good, my only doubt is that this lib uses pm2 to keep it running, how you should put this together?
remicastaing commentedon Sep 2, 2014
Absolutely no idea! I just googled it to find if someone else already wrote something to deploy apps with grunt on ec2.
nschurmann commentedon Sep 2, 2014
@JaKXz for now my deployment strategy is mainly using git.
Just code as you always do and when you need to deploy go into de server, do a pull to a specific commit (the production branch) and then start testing, if something goes wrong then you can make a rollback to a specific commit that used to work.
nschurmann commentedon Sep 2, 2014
Of course this is the manual process, an automated process should be a script or command line tool that logins to your amazon ec2 instance, navigate to the folder, make a backup, pull latest changes.
And also receive a command that can make a rollback (get into server, navigate to folder, put back the backup).
nschurmann commentedon Sep 2, 2014
I was missing the command that kept the application, after some time googling i found that this:
nohup grunt serve:dist --force &works quite well. The
--forceparam is needed because there is no desktop environment (because is a server) and prevents from failing at the very end.nohupis for no hangup and the & is for running in background.If you still don't recover the control of the command line just press enter, it should do the trick.
thomporter commentedon Sep 2, 2014
I haven no ec2/node experience (yet,) but this article describes a method using forever, which is a nice node module for keeping your app alive. There is another one here and more by googling "ec2 node forever"
nschurmann commentedon Sep 4, 2014
@thomporter you know how to use this with servers launched with grunt?
thomporter commentedon Sep 4, 2014
You won't launch the server with grunt this way. You should only be using grunt to launch your server for development. In production, grunt will just get in the way..
But, I believe this is the core command you'd need:
Let me know if that helps. If not, I might try setting up an ec2 instance myself and see if I can't get the demo project running on it.
P.S You'll need to install forever globally first:
npm install -g foreverthomporter commentedon Sep 4, 2014
I was able to get our demo app running on an ec2 instance will fairly little hassle...
http://ec2-54-68-53-8.us-west-2.compute.amazonaws.com:8080/
I used the Ubuntu ec2 instance.
Once in, I setup a few things. First, I created a new user "appuser" to run the app as and setup my public key:
I also installed mongo, ruby & sass
Then I logged into the server as the app user, and installed NVM:
Next I setup node:
Then I installed yo & forever, and our generator:
Next I built a simple app:
I built it with everything, though I didn't actually setup the passport stuff for 3rd parties, not sure why I even enabled them, but I did. =)
Next I setup my environment:
I built the app:
Lastly, I launched it:
The & at the end tells the process to run in the background, so I can log out even and it will keep running.
remicastaing commentedon Sep 4, 2014
Well, but @thomporter you didn't deploy an app on ec2, you build an app from scratch on an ec2 instance.
For openshift, the generator help to build an app locally and then help to deploy it on an openshift gear.
thomporter commentedon Sep 4, 2014
Shouldn't be a problem. Build your app locally and just copy the dist
folder up to the server...
nschurmann commentedon Sep 4, 2014
Totally loved this. Now i can deploy with forever.
2014-09-04 16:10 GMT-04:00 Thomas Porter notifications@github.com:
11 remaining items
eduals commentedon Nov 1, 2014
Awesome @mescalito
rgr2k commentedon Nov 12, 2014
sucks !!!
tinisasa commentedon Apr 15, 2015
@mescalito you rock!
wmyers commentedon Apr 29, 2015
@mescalito there's a lot of really useful stuff in your recipe.
One possible issue - if you are binding the NODE_ENV setting to when git commits from the client (which stops and restarts forever process manager), what happens if the server restarts for a different reason? Presumably the production env would not get passed...
This link is quite handy
Btw I'm not crazy about the lack of comments in the angular-fullstack Gruntfile but it is still a great free resource.
Geoide commentedon Jul 17, 2015
Yes, .bash_profile solution :)
Awk34 commentedon Jan 7, 2016
@victorhugoviiii That's because any running process will close once you close a terminal session. Using something like
nohup node server/app > logshould work.chinnichaitanya commentedon Jan 7, 2016
You can use pm2 too. It has many more features.
Tom2277 commentedon Apr 20, 2016
thanks @mescalito I used most of your recipe to deploy on AWS EC2 . I also got a mongo DB working
I'll share a couple things that I worked through :
I couldn't figure out how to push a single directory (dist) from within an existing git repo(I do want to track my entire project) into the new distrepo . I opted for cutting and pasting the dist files into the separate distrepo I tried all sorts of git subtree stuff but finally decided copying and replacing all wouldn't be much a burden.
on a mac that "puttykeyfile" or any other names I guessed didn't work. I worked around it using first two lines mescalito put in his gitconfig file and then I easily set a ssh on my mac like this:
ssh-add /Users/tomn/documents/projects/awskeystorage/ThisProjectPair.pemI used @wmyers suggested link and setup bash to set the NODE_ENV to production:
$ echo export NODE_ENV=production >> ~/.bash_profile$ source ~/.bash_profileit just seemed more straightforward and more useful in other cases of server shutdown than the .sh file
I got a mongodb working using directions here http://programmersdiary.com/node/deploy-mean-stack-app-on-amazon-ec2/ and here https://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
IF you followed 3 and set NODE_ENV to production you'll avoid npm install intalling all of dev dependencies avoiding much of - Dependencies unmet: I had hundreds of warnings I believe due to my initial attempts to compile via grunt instead of using the mescalitos technique of pushing dist.
note: node comes with an old npm version and 'npm update' doesn't update it. You should google around but worked for me was 'sudo npm install -g forever' TWICE first time didn't do it. http://askubuntu.com/questions/562417/how-do-you-update-npm-to-the-latest-version again might be a better more current way for that.
Note 2: AWS ec2 instances evidently go awry with some frequency. I spoke to a AWS support person at their pop-up loft in SF and he advised me that a very very early thing to try when things start working is to launch a new EC2 instance and try your code on that before assuming your code is at fault. "is the cord plugged in" debugging almost. I wasted a couple weeks looking for issues with my passport-facebook and passport-twitter ouath which went away after I launched a new ec2 instance.
duncan-p commentedon Jun 13, 2016
I know this issue is quite old now and there has been some good input already on deploying to AWS, but in case anyone is interested, here's a guide I put together for my team detailing the steps needed to take an Angular Fullstack app from development to production using AWS OpsWorks.
https://github.com/proxy/gist.github.com/duncan-p/8b8df883babf65c0350a6c2553d864ab
I know this differs from Heroku/Openshift deployment in that it doesn't push directly to your production servers, but I'm a huge fan of OpsWorks and since I started using it a year or so ago, I haven't looked back.
The biggest advantage for me is it gives Devs and QA testers the power to launch a new instance with a couple of clicks and have their server up-and-running with the latest tagged version of the app in a couple of minutes.