Deploying To Production on Heroku with Puma Discussion
So chris im using this on my db.yml file
production:
<<: *default
host: xxxxxxx
database: xxxxxx
password: xxxxx
port: xxxxxx
username:xxxxx
on your video you paste this code
production:
url: <%= ENV["DATABASE_URL"] %>
pool: <%= ENV["DB_POOL"] || ENV['MAX_THREADS'] || 5 %>
• form my db.yml code what parts I need to change.
• on heroku Config Vars I only have the DATABASE_URL its the DB_POOL build by puma??
thank you.
Heroku really only recommends the two lines for url and pool. The rest of that is all handled by Heroku. The DB_POOL may not be set, which will default it to 5 which is fine. You'll be able to easily change that as you scale up your Heroku servers.
Do you know a good resource for setting this up with mongoid?
Great question Jeff. I think Mongoid's docs do a pretty good job outlining the difference between it and ActiveRecord here: https://docs.mongodb.org/ec...
Chris, great video again. I had to go thru this 2 weeks ago and I wish I had this video back then. I've got a question which is not about this video, but about the very next step after deploying your app on heroku. So I had bought a custom domain (with google) and set up CNAME/ALIAS records with the pointDNS heroku addon. After that I realized that I need to configure my app over https if I use the custom domain instead of xyz.herokuapp.com. I read a bunch of articles, but still not sure what to choose. If it is possible I'd like to avoid the basic heroku addon solution since it costs $20/month. I've also seen the cloudfare free plan solution (https://www.cloudflare.com/..., but I'm not sure if it's good enough for production. Can you tell us/me pls, which one is the preferred solution here in general (not only from these 2 that I mentioned)?
Your cheapest option would be to use Cloudflare's flexible SSL. You wouldn't have to pay for the $20/mo for SSL hosting on Heroku that way. There are some other SSL options that Cloudflare provides but I think they cost money. https://www.cloudflare.com/...
Also most places require you to purchase an SSL certificate, but you may want to check out Let's Encrypt which let's you get a free SSL certificate. https://letsencrypt.org/
Hi Chris, I'm trying to follow along with this, but I'm stuck at the point where you use mvim to make a procfile. I don't know what mvim is (and if I have it, I don't know how to use it). I don't know how to make a procfile. I found someone on SO who is stuck with the same thing. Adapting their attempt, I did this in my terminal: echo "web: bundle exec puma -C config/puma.rb" > Procfile. Is that going to work to make a procfile? Thanks Mel
You can do that, but you can also just use your normal text editor to create and edit the file. Macvim is just what I use.
Hi Chris, i tried this. My database.yml now looks like yours. Now, when I try to precompile assets i get an error in my terminal that says:
ActiveRecord::AdapterNotSpecified: database configuration does not specify adapter
My default specifies psql
It may be useful to note that ActionCable can work with Unicorn: https://github.com/rails/ra...
Hey chris, if we have everything except the procfile...does this mean that puma is not going to start working on heroku?
My chat with actioncable + redis works 100% fine still.
Hey Chris, if I have this setup in puma.rb
workers Integer(2)
threads_count = Integer(5)
do I have to set my database.yml pool to 10? (each thread gets their own db connection?)
production:
url: <%= ENV['DATABASE_URL'] %>
pool: 10
Yeah, that should be correct. You'd multiple the two together to get your minimum pool size since each thread would need a database connection to operate (since they're doing the work).
Your app would look like this:
worker 1
-> thread
-> thread
-> thread
-> thread
-> thread
worker 2
-> thread
-> thread
-> thread
-> thread
-> thread
You can now add a "Release Phase" to Heroku Procfile to script automatically the rake db:migrate, e.g.
release: bundle exec rake db:migrate