All Projects → sorah → revision_plate

sorah / revision_plate

Licence: MIT License
Rack application and middleware that serves endpoint returns application's REVISION.

Programming Languages

ruby
36898 projects - #4 most used programming language

RevisionPlate

Rack application and middleware that serves endpoint returns application's REVISION.

Detail

The endpoint returns content of REVISION

Content of the endpoint wouldn't be changed even if REVISION file has changed. But it'll return 404 when it has removed.

This can be used for health check + remove from service by hand.

This gem is used in Cookpad. And seems several companies runs similar thing (e.g. GitHub).

Usage

typical Rails app

# Gemfile
gem 'revision_plate', require: 'revision_plate/rails'

then your Rails application will handle /site/sha.

rack application

# Gemfile
gem 'revision_plate'

# config.ru (middleware)
use RevisionPlate::Middleware, '/site/sha', "#{__dir__}/REVISION"

# config.ru (mount)
map '/site/sha' do
  run RevisionPlate::App.new("#{__dir__}/REVISION")
end

Test

$ echo 'deadbeef' > REVISION
$ (... start your app ...)
$ curl localhost:3000/site/sha
deadbeef
$ rm REVISION
$ curl localhost:3000/site/sha
REVISION_FILE_REMOVED

Advanced

I want to customize (Rails app)

remove require: 'revision_plate/rails' from Gemfile, then initialize RevisionPlate::App on routes:

# routes.rb
get '/site/sha' => RevisionPlate::App.new
get '/site/sha' => RevisionPlate::App.new("/path/to/my/favorite/REVISION")

Development

Testing

$ rake test

License

MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].