Custom Puma executable for a Ruby app
Sometimes I don’t like having to create required files and directories. This executable can serve your app via puma without having to create config.ru
and stuff.
Example bin/serve
file (the Web.freeze.app
is a Roda app):
#!/usr/bin/env ruby
$LOAD_PATH.unshift File.dirname(__dir__) + '/lib'
require 'rubygems'
require 'bundler/setup'
require 'web'
require 'puma'
require 'puma/launcher'
config = Puma::Configuration.new({}) do |c|
c.app Web.freeze.app
c.port 3000
c.threads 0, 5
end
config.load
Puma::Launcher.new(config).run
Code snippets in this post are covered by 0BSD License.