Feature Request: Allow static files in public directory without rackup file
Opening this for discussion. Related to https://github.com/puma/puma-dev/issues/44.
Pow allows you to serve a completely static website as long as it has a public directory. No Gemfile (with puma) nor a rackup file (config.ru) is necessary. This effectively becomes a really easy way to serve a virtual host in development for static sites.
Is it within the scope of puma-dev to more directly mimic this static public directory behavior for completely static sites?
Right now, puma-dev will return an unexpected exit with the following log for a static site with just a public directory and no rackup file.
{"time":"2016-10-20 11:39:47.8902328 -0600 MDT","event":"app_lookup","path":"/Users/me/.puma-dev/myapp"}
{"time":"2016-10-20 11:39:47.893756725 -0600 MDT","event":"booting_app","app":"myapp","socket":"/Users/me/.puma-dev/myapp/tmp/puma-dev-3740.sock"}
{"time":"2016-10-20 11:39:47.893865742 -0600 MDT","event":"waiting_on_app","app":"myapp"}
{"time":"2016-10-20 11:39:49.05906731 -0600 MDT","event":"killing_app","app":"myapp","pid":58675,"reason":"stdout/stderr closed"}
{"time":"2016-10-20 11:39:49.05915872 -0600 MDT","event":"shutdown","app":"myapp"}
{"time":"2016-10-20 11:39:49.059184475 -0600 MDT","event":"lookup_error","error":"unexpected exit"}
{"time":"2016-10-20 11:39:49.059199656 -0600 MDT","event":"dying_on_start","app":"myapp"}
In lieu of serving bare static sites from public, it would be great to get an example of the minimal config (Gemfile, config.ru βΒ whatever the bare minimum is that's required) to get a simple static site serving with puma dev.
Managed to run a static page with the following config. As a basement, I used this Heroku Rack setup:
π https://devcenter.heroku.com/articles/static-sites-ruby
$ tree static-site
static-site
βββ Gemfile
βββ config.ru
ββββ public
βββ css
β βββ styles.css
βββ images
β βββ demo.png
βββ index.html
βββ js
βββ app.js
Additional added gem 'puma' to Gemfile:
# Gemfile
source 'https://rubygems.org'
gem 'rack'
gem 'puma'
config.ru is a copy of the Heroku article
# config.ru
use Rack::Static,
:urls => ["/images", "/js", "/css"],
:root => "public"
run lambda { |env|
[
200,
{
'Content-Type' => 'text/html',
'Cache-Control' => 'public, max-age=86400'
},
File.open('public/index.html', File::RDONLY)
]
}
$ puma-dev link
$ open http://static-site.dev
Page is running, with images, stylesheets, and javascript π