capistrano-kitchen 0.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/.rspec +2 -0
- data/.ruby-gemset.template +1 -0
- data/.ruby-version.template +1 -0
- data/.travis.yml +7 -0
- data/.yardopts +5 -0
- data/Gemfile +8 -0
- data/Guardfile +13 -0
- data/LICENSE.txt +46 -0
- data/Rakefile +14 -0
- data/capistrano-kitchen.gemspec +29 -0
- data/lib/capistrano-kitchen.rb +41 -0
- data/lib/capistrano_kitchen/dishes/aptitude/manage.rb +38 -0
- data/lib/capistrano_kitchen/dishes/bundler/hooks.rb +7 -0
- data/lib/capistrano_kitchen/dishes/bundler/install.rb +79 -0
- data/lib/capistrano_kitchen/dishes/git/hooks.rb +3 -0
- data/lib/capistrano_kitchen/dishes/git/install.rb +18 -0
- data/lib/capistrano_kitchen/dishes/java_7_oracle/hooks.rb +5 -0
- data/lib/capistrano_kitchen/dishes/java_7_oracle/install.rb +17 -0
- data/lib/capistrano_kitchen/dishes/nginx_unicorn/app.conf +66 -0
- data/lib/capistrano_kitchen/dishes/nginx_unicorn/hooks.rb +11 -0
- data/lib/capistrano_kitchen/dishes/nginx_unicorn/install.rb +176 -0
- data/lib/capistrano_kitchen/dishes/nginx_unicorn/manage.rb +1 -0
- data/lib/capistrano_kitchen/dishes/nginx_unicorn/mime.types.erb +79 -0
- data/lib/capistrano_kitchen/dishes/nginx_unicorn/nginx.conf +138 -0
- data/lib/capistrano_kitchen/dishes/nginx_unicorn/nginx_unicorn.god +47 -0
- data/lib/capistrano_kitchen/dishes/nginx_unicorn/nginx_unicorn.init +95 -0
- data/lib/capistrano_kitchen/dishes/nginx_unicorn/nginx_unicorn.logrotate +18 -0
- data/lib/capistrano_kitchen/dishes/nginx_unicorn/stub_status.conf +16 -0
- data/lib/capistrano_kitchen/dishes/nodejs/hooks.rb +4 -0
- data/lib/capistrano_kitchen/dishes/nodejs/install.rb +13 -0
- data/lib/capistrano_kitchen/dishes/provision/empty_roles.rb +60 -0
- data/lib/capistrano_kitchen/dishes/provision/manage.rb +49 -0
- data/lib/capistrano_kitchen/dishes/provision/task_once.rb +62 -0
- data/lib/capistrano_kitchen/dishes/ruby/hooks.rb +7 -0
- data/lib/capistrano_kitchen/dishes/ruby/install.rb +55 -0
- data/lib/capistrano_kitchen/dishes/teelogger/teelogger.rb +121 -0
- data/lib/capistrano_kitchen/dishes/unicorn/hooks.rb +9 -0
- data/lib/capistrano_kitchen/dishes/unicorn/install.rb +120 -0
- data/lib/capistrano_kitchen/dishes/unicorn/unicorn.god +71 -0
- data/lib/capistrano_kitchen/dishes/unicorn/unicorn.rb.erb +191 -0
- data/lib/capistrano_kitchen/recipes/aptitude.rb +1 -0
- data/lib/capistrano_kitchen/recipes/bundler.rb +1 -0
- data/lib/capistrano_kitchen/recipes/git.rb +1 -0
- data/lib/capistrano_kitchen/recipes/java_7_oracle.rb +1 -0
- data/lib/capistrano_kitchen/recipes/nginx_unicorn.rb +1 -0
- data/lib/capistrano_kitchen/recipes/nodejs.rb +1 -0
- data/lib/capistrano_kitchen/recipes/provision.rb +1 -0
- data/lib/capistrano_kitchen/recipes/ruby.rb +1 -0
- data/lib/capistrano_kitchen/recipes/teelogger.rb +1 -0
- data/lib/capistrano_kitchen/recipes/unicorn.rb +1 -0
- data/lib/capistrano_kitchen/recipes/utilities.rb +442 -0
- data/lib/capistrano_kitchen/version.rb +3 -0
- data/spec/capistrano_kitchen_spec.rb +5 -0
- data/spec/spec_helper.rb +21 -0
- metadata +200 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: db4ffde20228c20e15ba55fe62d5063f3b67a535
|
4
|
+
data.tar.gz: 270fd49df9d461cfbb2e519cd81373ab74348d35
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c53fc7f8134e9541f3d16da43aaea2fa930f664eee19a6f512506af5a101eaf476040bc3f07cec2e60ef81a5886f545908873860d369df376d3552e7c9f3d810
|
7
|
+
data.tar.gz: cf931135a07e5a0d2bc0c17b6e741bf5ff5105e63374e7f8dafa1082fb2b3f0dcef3cfe1b8b14cc0367fd618f420aa7896c5cca02bd0a2fdaae2f41887fc0e63
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
.ruby-gemset
|
19
|
+
.ruby-version
|
20
|
+
# Mac OS X hidden files
|
21
|
+
.DS_Store
|
22
|
+
.rvmrc
|
23
|
+
.rbenv-version
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
capistrano-kitchen
|
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.1.0
|
data/.travis.yml
ADDED
data/.yardopts
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# More info at https://github.com/guard/guard#readme
|
2
|
+
|
3
|
+
guard :bundler do
|
4
|
+
watch('Gemfile')
|
5
|
+
watch(/^.+\.gemspec/)
|
6
|
+
end
|
7
|
+
|
8
|
+
guard :rspec do
|
9
|
+
watch(%r{^spec/.+_spec\.rb$})
|
10
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
11
|
+
watch('spec/spec_helper.rb') { "spec" }
|
12
|
+
end
|
13
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
Copyright (c) 2014 Donovan Bray (donnoman@donovanbray.com)
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
This software includes code originally appearing in the cap-recipes gem
|
25
|
+
covered by the following license:
|
26
|
+
|
27
|
+
Copyright (c) 2008 Nathan Esquenazi
|
28
|
+
|
29
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
30
|
+
a copy of this software and associated documentation files (the
|
31
|
+
"Software"), to deal in the Software without restriction, including
|
32
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
33
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
34
|
+
permit persons to whom the Software is furnished to do so, subject to
|
35
|
+
the following conditions:
|
36
|
+
|
37
|
+
The above copyright notice and this permission notice shall be
|
38
|
+
included in all copies or substantial portions of the Software.
|
39
|
+
|
40
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
41
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
42
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
43
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
44
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
45
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
46
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
RSpec::Core::RakeTask.new
|
5
|
+
task :default => :spec
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
RDoc::Task.new do |rdoc|
|
9
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
10
|
+
rdoc.main = 'README.md'
|
11
|
+
rdoc.rdoc_dir = 'rdoc'
|
12
|
+
rdoc.title = "CapistranoKitchen #{version} Documentation"
|
13
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
14
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'capistrano_kitchen/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "capistrano-kitchen"
|
8
|
+
spec.version = CapistranoKitchen::VERSION
|
9
|
+
spec.authors = ["Donovan Bray"]
|
10
|
+
spec.email = ["donnoman@donovanbray.com"]
|
11
|
+
spec.summary = %q{Everything including the kitchen sink for cooking with Capistrano 3}
|
12
|
+
spec.description = %q{Ubuntu Provisioning Recipes for Capistrano 3}
|
13
|
+
spec.homepage = "http://github.com/donnoman/capistrano-kitchen"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec", "~> 2.14.0"
|
24
|
+
spec.add_development_dependency "yard"
|
25
|
+
spec.add_development_dependency "yard-redcarpet-ext"
|
26
|
+
spec.add_development_dependency "debugger"
|
27
|
+
|
28
|
+
spec.add_dependency "capistrano", "~>3.0.0"
|
29
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "capistrano_kitchen/version"
|
2
|
+
|
3
|
+
# @readme
|
4
|
+
# # CapistranoCook
|
5
|
+
#
|
6
|
+
# Ubuntu Provisioning Recipes for Capistrano 3
|
7
|
+
#
|
8
|
+
# ## Installation
|
9
|
+
#
|
10
|
+
# Add this line to your application's Gemfile:
|
11
|
+
#
|
12
|
+
# gem 'capistrano-cook'
|
13
|
+
#
|
14
|
+
# And then execute:
|
15
|
+
#
|
16
|
+
# $ bundle
|
17
|
+
#
|
18
|
+
# Or install it yourself as:
|
19
|
+
#
|
20
|
+
# $ gem install capistrano-cook
|
21
|
+
#
|
22
|
+
# ## Usage
|
23
|
+
#
|
24
|
+
# Cook everything:
|
25
|
+
#
|
26
|
+
# $ cap staging cook
|
27
|
+
#
|
28
|
+
# Cook a specific dish:
|
29
|
+
#
|
30
|
+
# $ cap staging cook:nginx_unicorn
|
31
|
+
#
|
32
|
+
# ## Contributing
|
33
|
+
#
|
34
|
+
# 1. Fork it ( http://github.com/<my-github-username>/capistrano-cook/fork )
|
35
|
+
# 2. Create your feature branch (`git checkout -b my-new-feature`)
|
36
|
+
# 3. Commit your changes (`git commit -am 'Add some feature'`)
|
37
|
+
# 4. Push to the branch (`git push origin my-new-feature`)
|
38
|
+
# 5. Create new Pull Request
|
39
|
+
module CapistranoKitchen
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../utilities')
|
2
|
+
|
3
|
+
Capistrano::Configuration.instance(true).load do
|
4
|
+
namespace :aptitude do
|
5
|
+
|
6
|
+
desc "Update aptitude package system"
|
7
|
+
task :update do
|
8
|
+
utilities.apt_update
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "Upgrade all installed packages on aptitude package system"
|
12
|
+
task :upgrade do
|
13
|
+
utilities.apt_update
|
14
|
+
utilities.apt_upgrade
|
15
|
+
utilities.apt_autoremove
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Installs a specified aptitude package"
|
19
|
+
task :install do
|
20
|
+
deb_pkg_name = utilities.ask "Enter name of the package(s) you wish to install:"
|
21
|
+
raise "Please specify deb_pkg_name" if deb_pkg_name == ''
|
22
|
+
logger.info "Updating packages..."
|
23
|
+
sudo "aptitude update"
|
24
|
+
logger.info "Installing #{deb_pkg_name}..."
|
25
|
+
utilities.apt_install deb_pkg_name
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "Removes a specified aptitude package"
|
29
|
+
task :remove do
|
30
|
+
deb_pkg_name = utilities.ask "Enter name of the package(s) you wish to remove:"
|
31
|
+
raise "Please specify deb_pkg_name" if deb_pkg_name == ''
|
32
|
+
logger.info "Updating packages..."
|
33
|
+
sudo "aptitude update"
|
34
|
+
logger.info "Removing #{deb_pkg_name}..."
|
35
|
+
utilities.sudo_with_input "apt-get remove --purge #{deb_pkg_name}", /^Do you want to continue\?/
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# @author Donovan Bray <donnoman@donovanbray.com>
|
2
|
+
Capistrano::Configuration.instance(true).load do
|
3
|
+
before "bundler:configure", "bundler:install"
|
4
|
+
before "deploy:finalize_update", "bundler:configure"
|
5
|
+
after "deploy:provision", "bundler:install"
|
6
|
+
after "deploy:restart", "bundler:save_bundle"
|
7
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# @author Donovan Bray <donnoman@donovanbray.com>
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../utilities')
|
3
|
+
|
4
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
5
|
+
|
6
|
+
namespace :bundler do
|
7
|
+
|
8
|
+
# Intelligent Bundler Handling, requires no rollbacks
|
9
|
+
# Each release gets their own bundle seeded from the last built bundle
|
10
|
+
# to make the deploys faster, and the running application doesn't
|
11
|
+
# get its bundle changed out from under it.
|
12
|
+
|
13
|
+
set :bundler_opts, %w(--deployment --no-color --quiet)
|
14
|
+
set(:bundler_exec) { base_ruby_path + "/bin/bundle" }
|
15
|
+
set(:bundler_dir) { "#{shared_path}/bundle" }
|
16
|
+
set(:bundler_deploy_dir) { "#{latest_release}/vendor/bundle" }
|
17
|
+
set :bundler_rubygems_minimum_ver, "1.8.25"
|
18
|
+
set(:bundler_ver_latest) { JSON.parse(open("https://rubygems.org/api/v1/gems/bundler.json").read)['version'] }
|
19
|
+
set(:bundler_ver) { utilities.suggest_version(:bundler_ver, bundler_ver_latest) }
|
20
|
+
set :bundler_user, nil # don't use sudo by default.
|
21
|
+
set :bundler_file, "Gemfile"
|
22
|
+
set :bundler_binstubs, true
|
23
|
+
set :bundler_clean, true
|
24
|
+
set :rake, "bundle exec rake"
|
25
|
+
|
26
|
+
def bundle(path=nil)
|
27
|
+
# Don't bother if there's no gemfile.
|
28
|
+
# optionally do it as a specific user to avoid permissions problems
|
29
|
+
# do as much as possible in a single 'run' for speed.
|
30
|
+
# had to remove the bundle check in order to always create the binstubs
|
31
|
+
# use the save_bundle task to 'memorialize' a good bundle
|
32
|
+
args = bundler_opts.dup
|
33
|
+
args << "--path #{path}" unless path.to_s.empty? || bundler_opts.include?("--system")
|
34
|
+
args << "--gemfile=#{bundler_file}" unless bundler_file == "Gemfile"
|
35
|
+
args << "--binstubs" if bundler_binstubs
|
36
|
+
args << "--clean" if bundler_clean && bundler_ver >= "1.3.0"
|
37
|
+
cmd = "cd #{latest_release}; if [ -f #{bundler_file} ]; then #{bundler_exec} install #{args.join(' ')}; fi"
|
38
|
+
if bundler_opts.include?('--system')
|
39
|
+
cmd = "#{sudo} sh -c '#{cmd}'"
|
40
|
+
elsif bundler_user and not bundler_user.empty?
|
41
|
+
cmd = "sudo -u #{bundler_user} sh -c '#{cmd}'"
|
42
|
+
end
|
43
|
+
utilities.run_with_input(cmd, /yes\/no/, "yes\n") # If prompted with git authenticity of host respond affirmatively.
|
44
|
+
end
|
45
|
+
|
46
|
+
desc "Update Rubygems to be compatible with bundler"
|
47
|
+
task :update_rubygems, :except => { :no_release => true } do
|
48
|
+
gem_ver = capture("#{base_ruby_path}/bin/gem --version 2> /dev/null").chomp
|
49
|
+
if gem_ver < bundler_rubygems_minimum_ver
|
50
|
+
logger.important "RubyGems needs to be udpated, has gem --version #{gem_ver}"
|
51
|
+
run "#{sudo} #{base_ruby_path}/bin/gem update --system #{bundler_rubygems_minimum_ver} || #{sudo} #{base_ruby_path}/bin/gem update --system" #if pinned version fails update to the latest.
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "Setup system to use bundler"
|
56
|
+
task :install, :except => { :no_release => true } do
|
57
|
+
update_rubygems
|
58
|
+
utilities.gem_install_only "bundler", bundler_ver
|
59
|
+
end
|
60
|
+
|
61
|
+
desc "Save the bundle to initialize the next bundle run"
|
62
|
+
task :save_bundle, :except => {:no_release => true } do
|
63
|
+
run "rm -rf #{bundler_dir}; cp -r #{bundler_deploy_dir} #{bundler_dir}"
|
64
|
+
end
|
65
|
+
|
66
|
+
desc "bundle the deploy"
|
67
|
+
task :configure, :except => {:no_release => true} do
|
68
|
+
run "mkdir -p #{bundler_dir}; rm -rf #{bundler_deploy_dir}; cp -r #{bundler_dir} #{bundler_deploy_dir}; rm -rf #{latest_release}/.bundle/config"
|
69
|
+
bundle bundler_deploy_dir
|
70
|
+
end
|
71
|
+
|
72
|
+
desc "delete the bundle cache dir"
|
73
|
+
task :reset_cache, :except => {:no_release => true} do
|
74
|
+
run "rm -rf #{bundler_dir}"
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../utilities')
|
2
|
+
|
3
|
+
Capistrano::Configuration.instance(true).load do
|
4
|
+
|
5
|
+
namespace :git do
|
6
|
+
|
7
|
+
desc "install git"
|
8
|
+
task :install, :except => {:no_release => true} do
|
9
|
+
utilities.apt_install_from_ppa("ppa:git-core/ppa","git-core")
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "git version"
|
13
|
+
task :version, :except => {:no_release => true} do
|
14
|
+
run "git --version"
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../utilities')
|
2
|
+
|
3
|
+
Capistrano::Configuration.instance(true).load do
|
4
|
+
|
5
|
+
namespace :java_7_oracle do
|
6
|
+
roles[:java_7_oracle]
|
7
|
+
|
8
|
+
desc "install java_7_oracle"
|
9
|
+
task :install, :roles => :java_7_oracle do
|
10
|
+
run "#{sudo} echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | #{sudo} /usr/bin/debconf-set-selections"
|
11
|
+
utilities.apt_install_from_ppa "ppa:webupd8team/java","oracle-java7-installer"
|
12
|
+
run "#{sudo} update-java-alternatives -s java-7-oracle"
|
13
|
+
utilities.apt_install "oracle-java7-set-default"
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
<% if nginx_unicorn_rid_header_patch -%>
|
2
|
+
log_format <%=application%> '<%=application%>: $remote_addr - $remote_user [$time_local] "$http_x_forwarded_for" "$http_user_agent" $scheme $http_host "$request" $status - http_referer "$http_referer" http_x_forwarded_proto "$http_x_forwarded_proto" request_time $request_time upstream_response_time $upstream_response_time upstream_cache_status $upstream_cache_status http_x_request_id "$http_x_request_id" request_id "$request_id"';
|
3
|
+
<% else -%>
|
4
|
+
log_format <%=application%> '<%=application%>: $remote_addr - $remote_user [$time_local] "$http_x_forwarded_for" "$http_user_agent" $scheme $http_host "$request" $status - http_referer "$http_referer" http_x_forwarded_proto "$http_x_forwarded_proto" request_time $request_time upstream_response_time $upstream_response_time upstream_cache_status $upstream_cache_status';
|
5
|
+
<% end -%>
|
6
|
+
|
7
|
+
server {
|
8
|
+
listen <%=nginx_unicorn_port%>;
|
9
|
+
server_name <%=nginx_unicorn_server_name%>;
|
10
|
+
root <%=deploy_to%>/current/public; # <--- be sure to point to 'public'!
|
11
|
+
|
12
|
+
<% if nginx_unicorn_syslog_patch %>
|
13
|
+
access_log syslog:info <%=application%>;
|
14
|
+
error_log syslog:info;
|
15
|
+
<% else %>
|
16
|
+
access_log <%=shared_path%>/log/nginx_<%=application%>_access.log <%=application%>;
|
17
|
+
error_log <%=shared_path%>/log/nginx_<%=application%>_error.log;
|
18
|
+
<% end %>
|
19
|
+
|
20
|
+
proxy_set_header X-Real-IP $remote_addr;
|
21
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
22
|
+
<%= "proxy_set_header X-Forwarded-Proto $scheme;" if nginx_unicorn_set_scheme %>
|
23
|
+
proxy_set_header Host $http_host;
|
24
|
+
|
25
|
+
proxy_redirect off;
|
26
|
+
|
27
|
+
<% if nginx_unicorn_use_503_instead_of_502 %>
|
28
|
+
error_page 502 =503 /50x.html;
|
29
|
+
location = /50x.html {
|
30
|
+
root <%=nginx_unicorn_root%>/html;
|
31
|
+
}
|
32
|
+
<% end %>
|
33
|
+
|
34
|
+
location ~ ^/(flash|pdf|images|javascripts|stylesheets|compiled|fonts|attachments)/ {
|
35
|
+
expires 180d;
|
36
|
+
access_log off;
|
37
|
+
}
|
38
|
+
|
39
|
+
# Rails 3 asset pipeline
|
40
|
+
location ~ ^/assets/ {
|
41
|
+
expires 1y;
|
42
|
+
add_header Cache-Control public;
|
43
|
+
|
44
|
+
# Some browsers still send conditional-GET requests if there's a
|
45
|
+
# Last-Modified header or an ETag header even if they haven't
|
46
|
+
# reached the expiry date sent in the Expires header.
|
47
|
+
add_header Last-Modified "";
|
48
|
+
add_header ETag "";
|
49
|
+
break;
|
50
|
+
}
|
51
|
+
|
52
|
+
location / {
|
53
|
+
if (!-f $request_filename) {
|
54
|
+
proxy_pass http://<%=application%>_unicorn;
|
55
|
+
break;
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
}
|
60
|
+
|
61
|
+
# Only one Upstream should exist.
|
62
|
+
upstream <%=application%>_unicorn {
|
63
|
+
# it is recommended to set “fail_timeout=0” for in your nginx configuration like this to have nginx always retry backends that may have had workers SIGKILL-ed due to timeouts.
|
64
|
+
# may be proxy_upstream_fail_timeout in our version of nginx
|
65
|
+
server unix:<%=nginx_unicorn_upstream_socket%> <%= nginx_unicorn_fail_timeout.nil? ? "" : "fail_timeout=#{nginx_unicorn_fail_timeout}"%>;
|
66
|
+
}
|