discourse/bin/rails
Loïc Guitaut 154224f109
DEV: Add Pitchfork alongside Unicorn (#35370)
This PR adds Pitchfork, as we want to move away from Unicorn ultimately.

Unicorn still boots by default, so there should be no disruption for
anyone.

To use Pitchfork instead of Unicorn, the `RUN_PITCHFORK` environment
variable must be set.
This will make `bin/rails s` and `config/unicorn_launcher` boot
Pitchfork. `unicorn_launcher` was patched because that way we can easily
switch between Unicorn and Pitchfork without having to change too many
things on the infra side.

The upgrader from the `docker_manager` plugin doesn’t work yet with
Pitchfork. This will be addressed in a future PR.
2025-10-24 11:08:23 +02:00

18 lines
515 B
Ruby
Executable file

#!/usr/bin/env ruby
# frozen_string_literal: true
if !ENV["RAILS_ENV"] && (ARGV[0] == "s" || ARGV[0] == "server") && Process.respond_to?(:fork)
ENV["UNICORN_PORT"] ||= "3000"
if ARGV[1] == "-p" && (port = ARGV[2].to_i) > 0
ENV["UNICORN_PORT"] = port.to_s
end
ENV["RAILS_LOGS_STDOUT"] ||= "1"
exec File.expand_path(ENV["RUN_PITCHFORK"] ? "pitchfork" : "unicorn", __dir__)
end
APP_PATH = File.expand_path("../config/application", __dir__)
require_relative "../config/boot"
require "rails/commands"