Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 58 lines (40 sloc) 1.4 KB
#!/usr/bin/env rackup -s thin -E none
require 'rubygems'
require 'rack/cache'
require 'rack/contrib'
$: << File.join(File.dirname(__FILE__), 'lib')
require 'imagery'
require 'config/env'
use Rack::Config do |env|
env['imagery.origin_host'] = ORIGIN_SERVER
# Add rack sendfile extension.
# Allows us to serve cache hits directly from file system
# by nginx (big speed boost). read:
STDERR.puts 'Using accel redirect (Shopify config).'
require 'imagery/middleware/accel_redirect'
use Imagery::AccelRedirect
use Rack::Sendfile
use Rack::ShowExceptions
# 1. Forget about stupid favicons
use Imagery::FaviconFilter
# 2. Log all other incoming requests
use Imagery::LoggedRequest
# 3. Override server name into something non embarrasing
use Imagery::ServerName
# 4. Content type needs to be present, default to attachment
use Rack::ContentType, "application/octet-stream"
# 5. Serve converted images directly from cache
use Rack::Cache,
:metastore => ENV['META_STORE'],
:entitystore => ENV['ENTITY_STORE']
# 6. handle PURGE requests
use Imagery::CachePurge
# 7. See if files already exist on remote host, if so handle them directly
use Imagery::RemoteProxy
# 8. Otherwise run the image server and produce the missing images