omakase_unicorn-rails 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +70 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/omakase_unicorn/rails/version.rb +5 -0
- data/lib/omakase_unicorn/rails.rb +38 -0
- data/lib/templates/conf/nginx-site.conf +48 -0
- data/lib/templates/conf/unicorn.conf.rb +36 -0
- data/lib/templates/plist/local.rails.app.plist +33 -0
- data/omakase_unicorn-rails.gemspec +27 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7a8281b3d0bb3542a6387eb8d00be76b24073782
|
4
|
+
data.tar.gz: 869de7c0cc4067b8de5d7b3b0098ae1fc3b29601
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3f3be68749bbe7c9b59bcbb1d4c7f71032a58d94adbcc5792693fa6e22f5a0c15c8e4f50ecb1829815f6f729f03781948dacb1945f8d808dd42e4499e27bf1d7
|
7
|
+
data.tar.gz: 17491bee7722e57b2e00c58a26532f6367c2e7995111fd8e16520887196f5e6b45d01ab4f97343032c805a9051b5ed938f569d3b2d3bddb34c531fc3ef0c7f9f
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 kawagu gko
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# OmakaseUnicorn::Rails
|
2
|
+
|
3
|
+
This gem generate unicorn.conf.rb and nginx.conf to use at development.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'omakase_unicorn-rails'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
### Generate unicorn.conf.rb, nginx-site.conf
|
20
|
+
```shell
|
21
|
+
[~/sites/app_name]$ bundle exec rails generate omakase_unicorn:rails:config install
|
22
|
+
create .project
|
23
|
+
create .project/nginx-site.conf
|
24
|
+
create .project/unicorn.conf.rb
|
25
|
+
create .project/local.rails.app_namea.plist
|
26
|
+
gsub .project/nginx-site.conf
|
27
|
+
gsub .project/nginx-site.conf
|
28
|
+
gsub .project/nginx-site.conf
|
29
|
+
gsub .project/unicorn.conf.rb
|
30
|
+
gsub .project/unicorn.conf.rb
|
31
|
+
gsub .project/local.rails.app_name.plist
|
32
|
+
gsub .project/local.rails.app_name.plist
|
33
|
+
gsub .project/local.rails.app_name.plist
|
34
|
+
gsub .project/local.rails.app_name.plist
|
35
|
+
gsub .project/local.rails.app_name.plist
|
36
|
+
```
|
37
|
+
```shell
|
38
|
+
# nginx
|
39
|
+
$ sudo ln ./.project/nginx-site.conf /etc/nginx/conf.d/
|
40
|
+
# unicorn
|
41
|
+
$ bundle exec unicorn -D -c ./.project/unicorn.conf.rb -E development
|
42
|
+
```
|
43
|
+
|
44
|
+
#### for OSX
|
45
|
+
```
|
46
|
+
$ cp ./.project/local.rails.app_name.plist ~/Library/LaunchAgents/
|
47
|
+
$ launchctl load -w ~/Library/LaunchAgents/local.rails.app_name.plist
|
48
|
+
$ launchctl start local.rails.app_name
|
49
|
+
```
|
50
|
+
|
51
|
+
### Generate self-signed certificate
|
52
|
+
```shell
|
53
|
+
openssl genrsa -out server.key 2048
|
54
|
+
openssl req -new -key server.key -out server.csr -subj '/C=JP/ST=Tokyo/L=Tokyo/O=Example Ltd./OU=Web/CN=example.com'
|
55
|
+
openssl x509 -in server.csr -days 3650 -req -signkey server.key > server.crt
|
56
|
+
rm server.csr
|
57
|
+
sudo mkdir -p /etc/ssl/certs
|
58
|
+
sudo mkdir -p /etc/ssl/private
|
59
|
+
sudo mv server.crt /etc/ssl/certs/ssl-cert-snakeoil.pem;
|
60
|
+
sudo mv server.key /etc/ssl/private/ssl-cert-snakeoil.key;
|
61
|
+
```
|
62
|
+
|
63
|
+
## Contributing
|
64
|
+
|
65
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/jiikko/omakase_unicorn-rails.
|
66
|
+
|
67
|
+
|
68
|
+
## License
|
69
|
+
|
70
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "omakase_unicorn/rails"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require "omakase_unicorn/rails/version"
|
2
|
+
require 'rails/generators'
|
3
|
+
|
4
|
+
module OmakaseUnicorn
|
5
|
+
module Rails
|
6
|
+
class ConfigGenerator < ::Rails::Generators::NamedBase
|
7
|
+
source_root File.expand_path('../..', __FILE__)
|
8
|
+
|
9
|
+
def init
|
10
|
+
directory "templates/conf", ".project"
|
11
|
+
copy_file "templates/plist/local.rails.app.plist", ".project/local.rails.#{app_name}.plist"
|
12
|
+
|
13
|
+
gsub_file '.project/nginx-site.conf', '{{sock_name}}', app_name
|
14
|
+
gsub_file '.project/nginx-site.conf', '{{server_name}}', "#{app_name}.local"
|
15
|
+
gsub_file '.project/nginx-site.conf', '{{root_path}}', root_path
|
16
|
+
|
17
|
+
gsub_file '.project/unicorn.conf.rb', '{{root_path}}', root_path
|
18
|
+
gsub_file '.project/unicorn.conf.rb', '{{sock_name}}', app_name
|
19
|
+
|
20
|
+
gsub_file ".project/local.rails.#{app_name}.plist", '{{app_name}}', app_name
|
21
|
+
gsub_file ".project/local.rails.#{app_name}.plist", '{{root_path}}', root_path
|
22
|
+
gsub_file ".project/local.rails.#{app_name}.plist", '{{gem_home}}', File.dirname(`which bundle`).to_s.gsub("/bin", "")
|
23
|
+
gsub_file ".project/local.rails.#{app_name}.plist", '{{bundle_path}}', File.dirname(`which bundle`).strip
|
24
|
+
gsub_file ".project/local.rails.#{app_name}.plist", '{{ruby_path}}', File.dirname(`which ruby`).strip
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def root_path
|
30
|
+
::Rails.root.to_s
|
31
|
+
end
|
32
|
+
|
33
|
+
def app_name
|
34
|
+
File.basename(::Rails.root).to_s
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
upstream app_server {
|
2
|
+
server unix://tmp/.{{sock_name}}.sock fail_timeout=0;
|
3
|
+
}
|
4
|
+
|
5
|
+
server {
|
6
|
+
listen 80;
|
7
|
+
root {{root_path}}/public;
|
8
|
+
server_name {{server_name}};
|
9
|
+
location / {
|
10
|
+
try_files $uri @app;
|
11
|
+
}
|
12
|
+
|
13
|
+
location @app {
|
14
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
15
|
+
proxy_set_header Host $http_host;
|
16
|
+
proxy_redirect off;
|
17
|
+
proxy_buffers 8 16k;
|
18
|
+
proxy_buffer_size 32k;
|
19
|
+
proxy_pass http://app_server;
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
server {
|
24
|
+
listen 443;
|
25
|
+
root {{root_path}}/public;
|
26
|
+
server_name {{server_name}};
|
27
|
+
location / {
|
28
|
+
try_files $uri @app;
|
29
|
+
}
|
30
|
+
|
31
|
+
ssl on;
|
32
|
+
ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem;
|
33
|
+
ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key;
|
34
|
+
ssl_session_timeout 5m;
|
35
|
+
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
|
36
|
+
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
|
37
|
+
ssl_prefer_server_ciphers on;
|
38
|
+
|
39
|
+
location @app {
|
40
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
41
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
42
|
+
proxy_set_header Host $http_host;
|
43
|
+
proxy_redirect off;
|
44
|
+
proxy_buffers 8 16k;
|
45
|
+
proxy_buffer_size 32k;
|
46
|
+
proxy_pass http://app_server;
|
47
|
+
}
|
48
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
app_root_path = "{{root_path}}"
|
2
|
+
|
3
|
+
worker_processes 4
|
4
|
+
working_directory app_root_path
|
5
|
+
listen "/tmp/.{{sock_name}}.sock", :backlog => 256
|
6
|
+
listen 8081
|
7
|
+
timeout 90
|
8
|
+
pid "#{app_root_path}/tmp/pids/unicorn.pid"
|
9
|
+
|
10
|
+
stderr_path "#{app_root_path}/log/unicorn.stderr.log"
|
11
|
+
stdout_path "#{app_root_path}/log/unicorn.stdout.log"
|
12
|
+
|
13
|
+
preload_app true
|
14
|
+
GC.respond_to?(:copy_on_write_friendly=) and
|
15
|
+
GC.copy_on_write_friendly = true
|
16
|
+
|
17
|
+
check_client_connection false
|
18
|
+
|
19
|
+
before_fork do |server, worker|
|
20
|
+
defined?(ActiveRecord::Base) and
|
21
|
+
ActiveRecord::Base.connection.disconnect!
|
22
|
+
|
23
|
+
old_pid = "#{server.config[:pid]}.oldbin"
|
24
|
+
if old_pid != server.pid
|
25
|
+
begin
|
26
|
+
sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
|
27
|
+
Process.kill(sig, File.read(old_pid).to_i)
|
28
|
+
rescue Errno::ENOENT, Errno::ESRCH
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
after_fork do |server, worker|
|
34
|
+
defined?(ActiveRecord::Base) and
|
35
|
+
ActiveRecord::Base.establish_connection
|
36
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>Label</key>
|
6
|
+
<string>local.rails.{{app_name}}</string>
|
7
|
+
<key>WorkingDirectory</key>
|
8
|
+
<string>{{root_path}}</string>
|
9
|
+
<key>EnvironmentVariables</key>
|
10
|
+
<dict>
|
11
|
+
<key>GEM_HOME</key>
|
12
|
+
<string>{{gem_home}}</string>
|
13
|
+
<key>PATH</key>
|
14
|
+
<string>{{bundle_path}}:{{ruby_path}}:/bin:/usr/bin:/bin:/usr/sbin</string>
|
15
|
+
</dict>
|
16
|
+
<key>ProgramArguments</key>
|
17
|
+
<array>
|
18
|
+
<string>{{bundle_path}}/bundle</string>
|
19
|
+
<string>exec</string>
|
20
|
+
<string>unicorn</string>
|
21
|
+
<string>-c</string>
|
22
|
+
<string>{{root_path}}/.project/unicorn.conf.rb</string>
|
23
|
+
<string>-E</string>
|
24
|
+
<string>development</string>
|
25
|
+
</array>
|
26
|
+
<key>StandardOutPath</key>
|
27
|
+
<string>{{root_path}}/log/local.rails.app.log</string>
|
28
|
+
<key>StandardErrorPath</key>
|
29
|
+
<string>{{root_path}}/log/local.rails.app.err.log</string>
|
30
|
+
<key>KeepAlive</key>
|
31
|
+
<true/>
|
32
|
+
</dict>
|
33
|
+
</plist>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'omakase_unicorn/rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "omakase_unicorn-rails"
|
8
|
+
spec.version = OmakaseUnicorn::Rails::VERSION
|
9
|
+
spec.authors = ["jiikko"]
|
10
|
+
spec.email = ["n905i.1214@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{generate config files.}
|
13
|
+
spec.description = %q{generate unicorn and nginx config file at development.}
|
14
|
+
spec.homepage = "https://github.com/jiikko/omakase_unicorn-rails"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
|
20
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omakase_unicorn-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- jiikko
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: generate unicorn and nginx config file at development.
|
42
|
+
email:
|
43
|
+
- n905i.1214@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- bin/console
|
54
|
+
- bin/setup
|
55
|
+
- lib/omakase_unicorn/rails.rb
|
56
|
+
- lib/omakase_unicorn/rails/version.rb
|
57
|
+
- lib/templates/conf/nginx-site.conf
|
58
|
+
- lib/templates/conf/unicorn.conf.rb
|
59
|
+
- lib/templates/plist/local.rails.app.plist
|
60
|
+
- omakase_unicorn-rails.gemspec
|
61
|
+
homepage: https://github.com/jiikko/omakase_unicorn-rails
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
metadata: {}
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 2.4.5
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: generate config files.
|
85
|
+
test_files: []
|