Skip to content
This repository was archived by the owner on Jul 29, 2026. It is now read-only.
This repository was archived by the owner on Jul 29, 2026. It is now read-only.

Amazon deployment #501

Open
Open

Description

@nschurmann

Is there a plan to build a command line that deploys and rollbacks to amazon web services?, that would be super useful.

Activity

  1. JaKXz commented on Aug 31, 2014

    @JaKXz
    Collaborator

    I would find this useful too. @nschurmann would you happen to have an implementation you could put into a PR?

  2. nschurmann commented on Sep 2, 2014

    @nschurmann
    Author

    @JaKXz i don't have an implementation, actually i'm trying to deploy the app into a debian server without any success.

  3. remicastaing commented on Sep 2, 2014

    @remicastaing
    Contributor

    Have you take a look at this: https://github.com/bevacqua/grunt-ec2?

  4. nschurmann commented on Sep 2, 2014

    @nschurmann
    Author

    @remicastaing looks good, my only doubt is that this lib uses pm2 to keep it running, how you should put this together?

  5. remicastaing commented on Sep 2, 2014

    @remicastaing
    Contributor

    Absolutely no idea! I just googled it to find if someone else already wrote something to deploy apps with grunt on ec2.

  6. nschurmann commented on Sep 2, 2014

    @nschurmann
    Author

    @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.

  7. nschurmann commented on Sep 2, 2014

    @nschurmann
    Author

    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).

  8. nschurmann commented on Sep 2, 2014

    @nschurmann
    Author

    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.

  9. thomporter commented on Sep 2, 2014

    @thomporter

    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"

  10. nschurmann commented on Sep 4, 2014

    @nschurmann
    Author

    @thomporter you know how to use this with servers launched with grunt?

  11. thomporter commented on Sep 4, 2014

    @thomporter

    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

  12. thomporter commented on Sep 4, 2014

    @thomporter

    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:

    sudo adduser appuser --system --disabled-password --group --shell /bin/bash
    cd /home/appuser
    mkdir .ssh
    cd .ssh
    echo "--paste your public key here--" >> authorized_keys
    chmod 600 authorized_keys
    

    I also installed mongo, ruby & sass

    sudo apt-get update
    sudo apt-get install mongodb ruby
    gem install sass
    

    Then I logged into the server as the app user, and installed NVM:

    curl https://github.com/raw/creationix/nvm/v0.15.0/install.sh | bash
    

    Next I setup node:

    nvm install v0.10.31
    nvm default v0.10.31
    

    Then I installed yo & forever, and our generator:

    npm install -g yo forever generator-angular-fullstack
    

    Next I built a simple app:

    mkdir ~/app && cd $_ && yo angular-fullstack
    

    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:

    export NODE_ENV="production"
    

    I built the app:

    grunt build
    

    Lastly, I launched it:

    cd dist
    forever server/app.js &
    

    The & at the end tells the process to run in the background, so I can log out even and it will keep running.

  13. remicastaing commented on Sep 4, 2014

    @remicastaing
    Contributor

    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.

  14. thomporter commented on Sep 4, 2014

    @thomporter

    Shouldn't be a problem. Build your app locally and just copy the dist
    folder up to the server...

  15. nschurmann commented on Sep 4, 2014

    @nschurmann
    Author

    Totally loved this. Now i can deploy with forever.

    2014-09-04 16:10 GMT-04:00 Thomas Porter notifications@github.com:

    Shouldn't be a problem. Build your app locally and just copy the dist
    folder up to the server...

    —
    Reply to this email directly or view it on GitHub
    #501 (comment)
    .

  16. 11 remaining items

  17. eduals commented on Nov 1, 2014

    @eduals

    Awesome @mescalito

  18. rgr2k commented on Nov 12, 2014

    @rgr2k

    sucks !!!

  19. tinisasa commented on Apr 15, 2015

    @tinisasa

    @mescalito you rock!

  20. wmyers commented on Apr 29, 2015

    @wmyers

    @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.

  21. Geoide commented on Jul 17, 2015

    @Geoide

    Yes, .bash_profile solution :)

  22. added this to the milestone on Sep 14, 2015
  23. self-assigned this
    on Sep 14, 2015
  24. Awk34 commented on Jan 7, 2016

    @Awk34
    Collaborator

    @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.

  25. chinnichaitanya commented on Jan 7, 2016

    @chinnichaitanya

    You can use pm2 too. It has many more features.

  26. Tom2277 commented on Apr 20, 2016

    @Tom2277

    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 :

    1. 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.

    2. 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

    3. 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

    4. 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.

  27. duncan-p commented on Jun 13, 2016

    @duncan-p

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions