Last active
December 16, 2020 15:04
-
-
Save en30/cc496602aa57992466eb0becfb9f8b29 to your computer and use it in GitHub Desktop.
Chotto Matte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ruby chotto_matte.rb bundle exec rails server |
Author
en30
commented
Dec 16, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment