Skip to content

Instantly share code, notes, and snippets.

@en30
Last active December 16, 2020 15:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save en30/cc496602aa57992466eb0becfb9f8b29 to your computer and use it in GitHub Desktop.
Save en30/cc496602aa57992466eb0becfb9f8b29 to your computer and use it in GitHub Desktop.
Chotto Matte
require_relative "boot"
require "rails/all"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module YourApp
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 6.1
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
config.after_initialize do
p "killing #{ENV["HOGE_PID"]}..."
Process.kill("TERM", ENV["HOGE_PID"].to_i)
end
end
end
if child_pid = fork
ENV["HOGE_PID"] = child_pid.to_s
puts "exec #{ARGV}"
sleep 5 # slow start
exec *ARGV
else
require "rack"
Rack::Server.start(
app: ->(_env) { [503, { "Content-Type" => "text/plain" }, ["chotto matte"]] },
Port: ENV.fetch("PORT", 3000),
)
end
$ ruby chotto_matte.rb bundle exec rails server
@en30
Copy link
Author

en30 commented Dec 16, 2020

demo

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