Using Heroku with Ruby on Rails - ruby-on-rails

I have two questions about general usage with Heroku and RoR:
1) after I deploy my application onto Heroku, how can I apply new changes that I make?
2) After I deploy my application to Heroku, how do I "turn off" the server so that I can run my app locally again via localhost:3000? (for development & testing purposes)
Thanks!

Assuming you are using git to manage your project, you apply changes to Heroku by pushing them. This might look something like this:
git push heroku master
This pushes the master branch of your git project to Heroku.
To "turn off" your app on Heroku, you can do two things:
$ heroku ps:scale web=0
This completely turns off the application. You can also put it in maintenance mode, which simply prevents traffic to it:
$ heroku maintenance:on
That said, you don't need to turn off your app on Heroku while developing locally. The two environments are completely independent of each other.

Hope this link helps for part 1. Should be able to commit and push your changes using git push heroku master.
https://devcenter.heroku.com/articles/git#tracking-your-app-in-git
For part 2: will scaling your dynos back to 0 work for your case?
How to stop an app on Heroku?

When you make a change, just push the git repository to heroku again withgit push heroku master.
The server will automatically restart with the changed system.
You seem to have a misconception. You can always run your local development server regardless of what Heroku is doing (unless some other service your app connects to would become confused, of course; but if that happens, there is probably something wrong with your design). Nonetheless, if you want to stop the application on Heroku, just scale it to zero web dynos: heroku ps:scale web=0.

Related

Deploying Rails on Staging and Production using Capistrano 3

i have a rails app developed with 4.2.6 and ruby 2.2.4. Its my application so I am the only one responsible for the development, testing and deployment.Now I have few questions related to deployment and would appreciate if someone can help me.
I have two separate servers on digital ocean for staging and production.So how can i deploy my application or what should be the order of deployment when i am done with the development and testing.So..
i should be deploying the code on Staging(quite obvious) and then after testing successfully, in the staging server, deploy it to the production.Is this the way to go ahead.
Or deploy the code on staging and after testing, just deploy the changes only to the production and restart the production server.
Moreover, having separate git repository for both pro and staging good or how should i proceed with code maintenance.
What is the best approach.Is there something which i really need to understand or missing.Kindly help me the goodies with deployment and what suits the best?
Thanks in advance.
First, Yes your first assumption is correct you run you app in development on your local machine then when you are satisfied you test in in a production like environment which is staging then if you test everything an its fine then do a final deploy to production where its ready to be accessed by your users.
Second you dont need to have different git repos for both you should have a main branch where everything goes when its ready for production most of the times this is called master....then for the feature you are working create a separate branch where the changes goes and this is the branch where you add new features to your application usually known as develop or the name of the feature or name bug you are fixing...capistrano will allow you to choose what branch to deploy
Third afer you install capistrano it generates 2 file a staging and production file in the directory config/deploy customize this individually place the ip or endpoin/url of staging server in staging.rb and for production server inproduction.rb

How can I deploy to production webpack+Rails?

I want to deploy my project in production, but I can find information how to do it, I follow this information to created my website: rails+webpack, and just say for heroku but I am not using heroku.
I will really appreciate if you can help me with this issue.
You might not be understanding what Heroku is, you can easily use Heroku to deploy your website by following the steps mentioned in the same guide you posted. Using the command git push heroku master will deploy your application to a unique Heroku address which you can open by using heroku open in the CLI.
So first you'll need to create a Heroku account and then download the Heroku CLI which is just an interface to use Heroku from the command line. And here's a great guide on how to deploy a Rails 5 application to Heroku, Heroku might seem a bit scary at first for beginners but it really is very simple.

Git push heroku master fails without error

I can't push to heroku after committing changes to my local git repo. Heroku authentication works, rails app is up and running, github push still works, and heroku push used to work up until now - when git push heroku master from local app root directory suddenly started failing without error message. Can only interrupt with Ctrl-C.
Haven't found hints anywhere online yet..
Here's a few tips to try debugging and see what's happening. First, check the Heroku dashboard and see if Heroku is up. It's been down a few times in the past. Next, set GIT_SSH=/pathto/yourscript, where yourscript invokes ssh with -vvv (for verbose debugging). See if it's a network connectivity issue. Third, see if your repository is heavily loaded with commits (like tons of Binary files in the Git index). Ours used to be slow, when we realized this, and split it nicely so that it worked great. We also raised a Heroku support ticket to perform git gc --prune --aggressive remotely on our repo, and the problem got resolved for us.

Using GIT in production Rails machines

Should my production Rails project use GIT? it will be easy for me to update the
servers and to push hot fixes, but what if I'll have a conflict during a pull?
and if I'll accidentally pull something wrong it make cause some downtime.
What is your advice on how to synch between the GIT repository & production?
Thanks
How about using a dedicated deployment system like Capistrano? It solves many of the issues you are trying to avoid.
Don't leave local changes on your production machines, and there is no risk of conflicts.
Production installs should pull from a dedicated branch/tag (e.g. use gitflow, production machines pull from the latest tag or simply master) - not the branch you regularly push to (develop, if you use git-flow).

Creating and deploying new Heroku applications with a Rails application hosted on Heroku

I have a rails application running on heroku. I would like to make that application to create & deploy other applications on heroku.
Since the Cedar stack allows writing to the filesystem I can generate the files needed for the new application. My question is how to issue the "heroku create" and "git push heroku master" commands for deployment.
Is there any gems out there / can I use the heroku CLI in heroku together with the ruby system call?
You can do everything that you need to do Heroku wise with the Heroku gem. Bear in mind though that this will need credentials to authenticate, so you'll need to be happy with storing these in the applications config.
From a git point of view, use ruby-git.
It's probably worth looking at making whatever it is you're making multi-tenanted so you don't have to worry about this problem, and also won't have to worry about hundreds of applications to maintain (updates, bugfixes and the like)

Resources