Skip to content

Compatibility with kamal #306

Description

@navidemad

Hi, I’m migrating an I/O-bound application from Puma to Falcon.
I’ve followed the official guide locally, but I’m wondering if there’s anything specific that needs to be configured in Kamal for deployment. Also i am using Net::HTTP to make my HTTP calls, should i move to Async::HTTP ?

config/deploy.yml:

  proxy:
  ssl: true
  host: foo.bar.fr
  app_port: 3000

falcon.rb:

#!/usr/bin/env -S falcon host
# frozen_string_literal: true

require "falcon/environment/rack"

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

service hostname do
  include Falcon::Environment::Rack

  # By default, Falcon uses Etc.nprocessors to set the count, which is likely incorrect on shared hosts like Heroku.
  # Review the following for guidance about how to find the right value for your app:
  # https://help.heroku.com/88G3XLA6/what-is-an-acceptable-amount-of-dyno-load
  # https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#workers
  count ENV.fetch("WEB_CONCURRENCY", 1).to_i

  # If using count > 1 you may want to preload your app to reduce memory usage and increase performance:
  # This file will be loaded in the main process before forking.
  preload "preload.rb"

  cache false
  verbose true

  endpoint Async::HTTP::Endpoint.parse("http://0.0.0.0:#{port}")
end

Dockerfile:
CMD ["bundle", "exec", "falcon", "host"]

bin/docker-entrypoint:

#!/bin/bash -e

# If running the rails server then create or migrate existing database
if [ "${@: -4:1}" == "bundle" ] && [ "${@: -3:1}" == "exec" ] && [ "${@: -2:1}" == "falcon" ] && [ "${@: -1:1}" == "host" ]; then
  ./bin/rails db:prepare
fi

exec "${@}"

Thanks

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions