rails_12factor 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +17 -32
- data/lib/rails_12factor/version.rb +1 -1
- data/rails_12factor.gemspec +2 -2
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2c21639f4ac7dee459a542944ceedd99e89b71f
|
4
|
+
data.tar.gz: 92010a998269ab120ced4cdc6b0214e240eaf1ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2bb874ff19b97341b568d5fa248cc90ec065e09ebb253fa204bee316f55cebe42d14e323f9e5b4783e6885933ece7b25c297dd5360572fadfa696b6e91d076b
|
7
|
+
data.tar.gz: d16f99f2632dc5493a00e5933a5364bf6392ffb8ca155393fca097cf9dbca0f00e99353aa0aec2ae047c33e60ffaea095a2ded16f432efa57f78e7d3eb56c04f
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,68 +1,53 @@
|
|
1
|
-
# Rails
|
1
|
+
# Rails 12factor
|
2
2
|
|
3
|
-
Makes running your Rails app on
|
3
|
+
Makes running your Rails app easier. Based on the ideas behind [12factor.net](http://twelve-factor.net)
|
4
4
|
|
5
5
|
## What
|
6
6
|
|
7
|
-
|
7
|
+
Rails gets a lot right when it comes to twelve-factor apps, but it could still be better. The two biggest areas right now is that in production [logs should be directed to stdout](http://www.twelve-factor.net/logs) and [dev/prod parity](http://www.twelve-factor.net/dev-prod-parity) while delivering assets.
|
8
|
+
|
9
|
+
This gem enables serving assets in production and setting your logger to standard out, both of which are required for to run a Rails 4 application on a twelve-factor provider.
|
8
10
|
|
9
11
|
## Install
|
10
12
|
|
11
13
|
In your `Gemfile` add:
|
12
14
|
|
13
|
-
```
|
14
|
-
gem 'rails_12factor'
|
15
|
+
```ruby
|
16
|
+
gem 'rails_12factor', group: :production
|
15
17
|
```
|
16
18
|
|
17
19
|
Then run
|
18
20
|
|
19
|
-
```
|
21
|
+
```sh
|
20
22
|
$ bundle install
|
21
23
|
```
|
22
24
|
|
23
|
-
Now you're good to go.
|
24
|
-
|
25
|
+
Now you're good to go.
|
25
26
|
|
26
27
|
## How
|
27
28
|
|
28
|
-
This gem adds two other gems `rails_serve_static_assets` and `rails_stdout_logging`.
|
29
|
+
This gem adds two other gems `rails_serve_static_assets` and `rails_stdout_logging`. These gems are required to run your Rails app with both logging aggregation and static assets serving in production. All you need to do to get the functionality of both gems is to add the `rails_twelve-factor` gem to your project. Here is how they work:
|
29
30
|
|
30
31
|
## Rails 4 Logging
|
31
32
|
|
32
|
-
By default Rails writes its logs to a file which is convenient
|
33
|
+
By default Rails writes its logs to a specific file, which is convenient if you only have one log file to tail. When you start scaling to multiple instances running your app, finding a single request or failure across multiple files becomes much harder. Storing logs on disk can also take down a server if the hard drive fills up. Because of these limitations, every Rails core member we’ve talked to uses a custom logger to replace Rail's default functionality. By using the `rails_stdout_logging` gem, the logger is set for you.
|
33
34
|
|
34
|
-
The gem `rails_stdout_logging` ensures that your logs will be sent to standard out, from there
|
35
|
+
The gem `rails_stdout_logging` ensures that your logs will be sent to standard out, and from there the twelve-factor platform can send them to a log aggregation service ( like [logplex](https://github.com/heroku/logplex) on Heroku, or [Papertrail](https://papertrailapp.com)) so you can access them from one place. By using stdout instead of files, you can [treat logs as event streams](http://www.twelve-factor.net/logs).
|
35
36
|
|
36
37
|
|
37
38
|
## Rails 4 Serve Static Assets
|
38
39
|
|
39
|
-
In the default Rails development environment assets are served through a middleware called [sprockets](https://github.com/sstephenson/sprockets). In production however most
|
40
|
+
In the default Rails development environment assets are served through a middleware called [sprockets](https://github.com/sstephenson/sprockets). In production however most one-off Rails deployments will put their ruby server behind a reverse HTTP proxy server such as Nginx, which can then load balance the app and serve static files directly. When Nginx sees a request for an asset such as `/assets/rails.png` it will grab it from disk at `/public/assets/rails.png` and serve it. The Rails server will never see these requests.
|
40
41
|
|
41
|
-
On
|
42
|
+
On a twelve-factor platform, Nginx is typically not required to run your application. Your app should be capable of handling requests directly, or through a [routing layer](https://devcenter.heroku.com/articles/http-routing) that may handles load balancing while you scale out horizontally. Note that the caching behavior of Nginx is not needed if your application is serving static assets through an [edge caching CDN](https://en.wikipedia.org/wiki/Content_delivery_network), which is generally recommended.
|
42
43
|
|
43
|
-
By default
|
44
|
+
By default Rails 4 will return a 404 if an asset is not handled via an external proxy such as Nginx. While this default behavior may help you debug your Nginx configuration, it makes a default Rails app with assets unusable on a twelve-factor platform. To fix this we've released a gem: `rails_serve_static_assets`.
|
44
45
|
|
45
|
-
|
46
|
-
|
47
|
-
```
|
48
|
-
config.serve_static_assets = true
|
49
|
-
```
|
46
|
+
The `rails_serve_static_assets` gem enables your Rails server to deliver your assets directly, instead of returning a 404. You can use this to populate an edge cache CDN, or serve files directly from your web app. This gives your app total control, allowing you to do things like redirects or setting headers in your Ruby code. The gem achives this behavior in your app by simply setting a single configuration option, `config.serve_static_assets = true`. By using the `rails_serve_static_assets` gem, you do not need to set this configuration manually.
|
50
47
|
|
51
|
-
Note: this gem will set this value for you, you don't need to change any configuration manually.
|
52
|
-
|
53
|
-
All you need to do to get this functionality of both gems is add the `rails_12factor` gem to your project.
|
54
|
-
|
55
|
-
## Why?
|
56
|
-
|
57
|
-
Why do you need to include this gem in Rails 4 and not Rails 3? Rails4 is getting rid of the concept of plugins. Before libraries were easily distributed as Gems and in the form of Engines, Rails had a folder `vendor/plugins`. Any code you put there would be initialized much like a Gem is today. This was a very simple and easy way to share and use libraries, but it wasn't very maintainable. You could use a library, and make a change locally and then deploy which makes your version incompatible from future versions. Even worse there was no concept of versioning aside from source control, so semantic versioning was out of the question. For these reasons and more Rails3 deprecated plugins. With Rails4 plugins have been removed completely. Why does this affect your app on Heroku?
|
58
|
-
|
59
|
-
In the past Heroku has used plugins as a safe way to configure your application where code was needed. While we advocate [separating config from code](http://12factor.net), this was the only option if we wanted your apps to work with no changes from you. With Rails3 Heroku will add the asset serving and standardout logging plugins to your app automatically. With Rails4, Heroku needs you to add these libraries to your Gemfile.
|
60
|
-
|
61
|
-
It is important to note that unlike Gems, plugins do not have a dependency resolution phase like what happens when you run `bundle install`. Heroku does not and will not add anything to your Gemfile on compilation.
|
62
48
|
|
63
49
|
|
64
50
|
## The Future
|
65
51
|
|
66
|
-
We will be working with Rails and the Rails core team to make future versions of Rails work on
|
67
|
-
|
52
|
+
We will be working with Rails and the Rails core team to make future versions of Rails work on twelve-factor platforms out of the box. Until then you'll need to add this gem to your project.
|
68
53
|
|
data/rails_12factor.gemspec
CHANGED
@@ -4,8 +4,8 @@ require File.expand_path('../lib/rails_12factor/version', __FILE__)
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ["Richard Schneeman", "Terence Lee"]
|
6
6
|
gem.email = ["richard@heroku.com", "terence@heroku.com"]
|
7
|
-
gem.description = %q{
|
8
|
-
gem.summary = %q{
|
7
|
+
gem.description = %q{Run Rails the 12factor way}
|
8
|
+
gem.summary = %q{ Following best practices from http://12factor.net run a maintainable, clean, and scalable app on Rails}
|
9
9
|
gem.homepage = "https://github.com/heroku/rails_12factor"
|
10
10
|
|
11
11
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_12factor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Schneeman
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- - '>='
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
|
-
description:
|
42
|
+
description: Run Rails the 12factor way
|
43
43
|
email:
|
44
44
|
- richard@heroku.com
|
45
45
|
- terence@heroku.com
|
@@ -78,5 +78,6 @@ rubyforge_project:
|
|
78
78
|
rubygems_version: 2.0.2
|
79
79
|
signing_key:
|
80
80
|
specification_version: 4
|
81
|
-
summary:
|
81
|
+
summary: Following best practices from http://12factor.net run a maintainable, clean,
|
82
|
+
and scalable app on Rails
|
82
83
|
test_files: []
|