xiaohongshu
xiaohongshu
async-falcon-rails
Transform a Rails application to use Falcon web server with async job processing (async-job), async Action Cable, and Redis-compatible database (Valkey for production). Use when the user wants to add async/Falcon stack to a Rails project, migrate from Puma to Falcon, or set up async job processin...
Full skill instructions
Transform a Rails application to use the Falcon web server with async job processing, async Action Cable, and Redis-compatible database (Valkey for production). This skill handles the complete migration from Puma to Falcon, configures async job adapters, sets up Redis/Valkey for Action Cable and job queues, and configures Kamal deployment for production.
Use this skill when the user:
Before applying this skill, verify:
Gemfile, config/application.rb)config/environments/ directorybundle command works)config/deploy.ymlFollow these steps in order to transform a Rails application to use the async/Falcon stack:
Replace Puma with Falcon and add async dependencies:
bundle remove puma
bundle add falcon
bundle add async-job-processor-redis
bundle add async-job-adapter-active_job
bundle add async-cable
bundle add redis
After running these commands, verify the Gemfile includes:
gem "falcon"gem "async-job-processor-redis"gem "async-job-adapter-active_job"gem "async-cable"gem "redis" (provides Async::Redis::Endpoint for endpoint parsing)CRITICAL: The async/Falcon stack requires OpenSSL development libraries to build properly. Without this, Docker builds will fail.
Edit the Dockerfile and add libssl-dev to the system dependencies.
Find the line that installs build packages (usually around line 40):
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential git libyaml-dev pkg-config && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives
Update it to include libssl-dev:
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential git libyaml-dev libssl-dev pkg-config && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives
Why this is needed: The Falcon web server and async gems depend on native extensions that require OpenSSL headers to compile. Without libssl-dev, the Docker build will fail with compilation errors.
Create config/initializers/async_job.rb with the following content:
require "async/job"
require "async/job/processor/aggregate"
require "async/job/processor/redis"
require "async/job/processor/inline"
require "async/redis/endpoint"
Rails.application.configure do
# Resolve Redis endpoint from REDIS_URL; fallback to localhost for dev/test.
redis_endpoint = Async::Redis::Endpoint.parse(
ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" }
)
config.async_job.define_queue "default" do
enqueue Async::Job::Processor::Aggregate
# Ensure the job runner connects to the accessory container (or localhost in dev).
dequeue Async::Job::Processor::Redis, endpoint: redis_endpoint
end
config.async_job.define_queue "local" do
dequeue Async::Job::Processor::Inline
end
end
This configuration:
Update Procfile.dev to include the async job processor:
Add this line to the existing Procfile.dev:
jobs: bundle exec async-job-adapter-active_job-server
The complete Procfile.dev should include at minimum:
web: bin/rails s
jobs: bundle exec async-job-adapter-active_job-server
If the project uses Vite or other frontend build tools, keep those lines as well.
Edit config/environments/development.rb to use async_job queue adapter.
Find the section about ActiveJob (usually near config.active_job.verbose_enqueue_logs) and add:
config.active_job.queue_adapter = :async_job
Edit config/environments/production.rb to configure both async_job and Redis cache:
Find and update or add these configurations:
# For cache store (usually around line 50)
config.cache_store = :redis_cache_store, { url: ENV["REDIS_URL"] }
# For queue adapter (usually around line 53)
config.active_job.queue_adapter = :async_job
Edit config/application.rb to add async/cable support:
require "rails/all", add:require "async/cable"
class Application < Rails::Application block, after config.load_defaults, add:# Configure async/fiber support
config.active_record.permanent_connection_checkout = :disallowed
config.active_support.isolation_level = :fiber
These settings enable fiber-based isolation for async operations.
Run the Rails generator to create the base Action Cable structure:
bin/rails generate channel BaseChannel
This creates:
app/channels/application_cable/channel.rbapp/channels/application_cable/connection.rbapp/channels/base_channel.rbtest/channels/base_channel_test.rbEdit config/routes.rb to mount the Action Cable server.
Add this line at the top of the Rails.application.routes.draw block:
mount ActionCable.server => '/cable'
Edit config/cable.yml to use Redis for all environments:
Update the configuration to:
development:
adapter: redis
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
channel_prefix: PROJECT_NAME_production
test:
adapter: test
production:
adapter: redis
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
channel_prefix: PROJECT_NAME_production
Replace PROJECT_NAME with the actual Rails application name (found in config/application.rb as the module name).
If the project uses Kamal for deployment (check for config/deploy.yml), update the deployment configuration:
In the servers: section, add or uncomment the job server configuration:
servers:
web:
- 192.168.0.1
job:
hosts:
- 192.168.0.1
cmd: bundle exec async-job-adapter-active_job-server
options:
init: true
Key configuration:
init: true: Skips health checks for the job server (avoids 30-second deployment wait)In the accessories: section (create if it doesn't exist), add Redis/Valkey configuration:
accessories:
redis:
image: valkey/valkey:9
host: 192.168.0.1
port: "127.0.0.1:6379:6379"
directories:
- redis_data:/data
Key considerations:
"127.0.0.1:6379:6379" prevents public exposure (localhost only)redis_data prevents conflicts with other services (e.g., PostgreSQL)In the env: section under clear:, add:
env:
clear:
REDIS_URL: redis://PROJECT_NAME-redis:6379/1
Replace PROJECT_NAME with the service name from the top of deploy.yml. The format follows Kamal's Docker naming convention: {service_name}-{accessory_name}.
Update the builder: section to support multiple architectures:
builder:
arch:
- amd64
- arm64
This enables building Docker images for:
After completing the workflow, verify the setup:
libssl-dev is included in the apt-get install lineconfig/initializers/async_job.rb exists and includes endpoint configuration (endpoint: redis_endpoint)async_job queue adapter in development.rb and production.rbasync/cable require and fiber isolation config in application.rbinit: true, Redis accessory, REDIS_URL, and multi-arch build config in deploy.ymlThis stack requires Redis-compatible database to be running:
redis-server or use DockerThe REDIS_URL environment variable must be set:
redis://localhost:6379/1 (configured in cable.yml)When using Kamal:
{service_name}-redisredis://{service_name}-redis:6379/1redis_data, postgres_data, etc.The Redis port binding "127.0.0.1:6379:6379" ensures:
If Docker build fails with compilation errors about OpenSSL or missing headers:
libssl-dev system dependency in Dockerfilelibssl-dev to the apt-get install line in Dockerfile (see Step 2)libssl-dev in the package list alongside build-essential, git, libyaml-dev, and pkg-configThis is a critical dependency for Falcon and async gems - without it, the Docker image cannot be built.
If bundle add commands fail:
bundle update to resolve dependency issuesIf the application cannot connect to Redis:
redis-cli ping should return PONG)If Kamal deployment fails:
kamal accessory details redisIf Kamal deployment hangs for 30 seconds when deploying the job server:
options: with init: true to the job server configuration in deploy.yml (see Step 11.1)init: true tells Kamal to skip health checks for this serviceFor detailed configuration templates and examples, see:
references/configuration-templates.md - Complete file templates and patternsxiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience