Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Things required to deploy to Heroku #53

Open
katafrakt opened this issue Nov 2, 2021 · 1 comment
Open

Things required to deploy to Heroku #53

katafrakt opened this issue Nov 2, 2021 · 1 comment

Comments

@katafrakt
Copy link
Contributor

Recently I have deployed an app from the template to Heroku and I needed to tweak a few things. Listing them here, so we can discuss which of them should make it to the code (I will be happy to prepare PRs, once we decide) - or at least be a checklist for someone else facing similar problems.

  1. Commit Gemfile.lock and yarn.lock currently the are in .gitignore and Heroku does not allow that (I see now it's partly addressed by b38df3a)
  2. Serve assets from /public

Currently there's this in config.ru:

use Rack::Static,
  urls: ["/assets"],
  root: ".assets/tmp",
  header_rules: [
    ["/assets", {"Cache-Control" => "public, max-age=31536000"}]
  ]

I had to change to root to root: ENV['PRECOMPILED_ASSETS'] == 'true' ? "public" : ".assets/tmp", so it serves precompiled assets from /public. I'm not really sure what's the deal with .assets directory though, so there might be other solution for this.

  1. Disconnect Sequel databases in Puma before_fork (Sequel::DATABASES.each(&:disconnect)) - I'm not sure here if it's something Hanami.shutdown should do, but for now manual disconnect is required.
@JuPlutonic
Copy link

JuPlutonic commented Sep 23, 2022

Not only for Heroku (starting November 28th free dynos will no longer be available). So for PaaS/VPS and for 12 factor app ideology all these three issues need to be implemented.
So, I solve 3rd issue/"graceful shutdown" with:

# Shutdown the application before forking
before_fork do
  @_app.shutdown if instance_variable_defined?(:@_app)
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants