socketry / falcon-rails-example

25 stars 1 forks source link

Possible optional info for README, some bits specific to Heroku #1

Open trevorturk opened 10 months ago

trevorturk commented 10 months ago

I'm happy to work up PRs if desirable (not sure if just adding optional sections to the README would be best?) but I wanted to share a few other bits from a Rails app I have running Falcon on Heroku:

falcon.rb preloads the app, disables caching, hooks into an ENV var which should match the CPU count (1 for Standard-1x dynes) and configures for HTTP1 (until they support HTTP2):

#!/usr/bin/env -S falcon host

load :rack

hostname = File.basename(__dir__)
port = ENV["PORT"] || 3000

rack hostname do
  append preload "preload.rb"
  cache false
  count ENV.fetch("FALCON_COUNT", 1).to_i
  endpoint Async::HTTP::Endpoint.parse("http://0.0.0.0:#{port}").with(protocol: Async::HTTP::Protocol::HTTP11)
end

preload.rb:

require_relative "config/environment"

Procfile:

web: bundle exec ./falcon.rb
trevorturk commented 4 months ago

/cc @ioquatix perhaps this'll change with the upcoming falcon/async-service stuff, but I wonder if we should consider adding a section about how to deploy this to Heroku, or even provide the config by default? (I'm happy to work up a PR if desirable...)

ioquatix commented 4 months ago

Yeah, I think it would be good to have an integration guide.