capistrano-unicorn-rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano3-unicorn.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Christopher Cocchi-Perrier
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ 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, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # Capistrano::Unicorn
2
+
3
+ Unicorn basic tasks for Capistrano v3:
4
+
5
+ - `cap unicorn:restart`
6
+ - `cap unicorn:stop`
7
+
8
+ There is no `start` task since Capistrano v3 only use `restart`. The `unicorn:restart`
9
+ will handle both the start and the restart of the unicorn server.
10
+
11
+ Some unicorn specific options
12
+
13
+ ```ruby
14
+ set :unicorn_rails_env, ->{ fetch :rails_env, "production" }
15
+ set :unicorn_pid_path, ->{ File.join(current_path, 'tmp', 'pids', 'unicorn.pid') }
16
+ set :unicorn_config_path, ->{ File.join(current_path, 'config', 'unicorn.rb') }
17
+ ```
18
+
19
+ The task will use the `unicorn_rails` binary to avoid unnecessary middleware added by
20
+ the `unicorn` binary (Rails already take care of that)
21
+
22
+ ## Installation
23
+
24
+ Add this line to your application's Gemfile:
25
+
26
+ gem 'capistrano-unicorn-rails'
27
+
28
+ ## Usage
29
+
30
+ Require `capistrano/unicorn` inside your `Capfile` to load all tasks.
31
+
32
+ By default, no task are automatically added since Capistrano will remove the default `deploy:restart` its version 3.1.
33
+ You'll need to invoke directly the task inside your `config/deploy.rb`
34
+
35
+ ```ruby
36
+ namespace :deploy do
37
+ desc 'Restart application'
38
+ task :restart do
39
+ invoke 'unicorn:restart'
40
+ end
41
+ end
42
+ ```
43
+
44
+ or
45
+
46
+ ```ruby
47
+ after 'deploy:published', 'unicorn:restart'
48
+ ```
49
+
50
+ ## Contributing
51
+
52
+ 1. Fork it
53
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
54
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
55
+ 4. Push to the branch (`git push origin my-new-feature`)
56
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'capistrano-unicorn-rails'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "capistrano-unicorn-rails"
8
+ spec.version = CapistranoUnicornRails::VERSION
9
+ spec.authors = ["ccocchi"]
10
+ spec.email = ["cocchi.c@gmail.com"]
11
+ spec.description = "Simple Unicorn! integration with Capistrano3 for Rails projects"
12
+ spec.summary = "Basic tasks for starting and stoping Unicorn! servers via capistrano tasks"
13
+ spec.homepage = "https://github.com/ccocchi/capistrano-unicorn-rails"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
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 'rake'
22
+
23
+ spec.add_runtime_dependency 'capistrano', '>= 3.0.1'
24
+ end
@@ -0,0 +1,3 @@
1
+ module CapistranoUnicornRails
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,33 @@
1
+ namespace :unicorn do
2
+ def send_signal(sig)
3
+ execute :kill, "-#{sig}", "`cat #{fetch(:unicorn_pid_path)}`"
4
+ end
5
+
6
+ desc "Start a fresh new unicorn server if not already running, otherwise restart the existing one"
7
+ task :restart do
8
+ on roles(:app, in: :sequence, wait: 5) do
9
+ within release_path do
10
+ if test("[ -s #{fetch(:unicorn_pid_path)} ]")
11
+ send_signal('USR2')
12
+ else
13
+ execute :bundle, :exec, :unicorn_rails, '-D', '-E', fetch(:unicorn_rails_env), '-c', fetch(:unicorn_config_path)
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ desc "Stop gracefully the unicorn server"
20
+ task :stop do
21
+ on roles(:app) do
22
+ send_signal('QUIT')
23
+ end
24
+ end
25
+ end
26
+
27
+ namespace :load do
28
+ task :defaults do
29
+ set :unicorn_rails_env, ->{ fetch :rails_env, "production" }
30
+ set :unicorn_pid_path, ->{ File.join(current_path, 'tmp', 'pids', 'unicorn.pid') }
31
+ set :unicorn_config_path, ->{ File.join(current_path, 'config', 'unicorn.rb') }
32
+ end
33
+ end
@@ -0,0 +1 @@
1
+ load File.expand_path('../tasks/unicorn.rake', __FILE__)
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-unicorn-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - ccocchi
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-01-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: capistrano
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 3.0.1
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 3.0.1
46
+ description: Simple Unicorn! integration with Capistrano3 for Rails projects
47
+ email:
48
+ - cocchi.c@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - Gemfile
55
+ - LICENSE
56
+ - README.md
57
+ - Rakefile
58
+ - capistrano-unicorn-rails.gemspec
59
+ - lib/capistrano-unicorn-rails.rb
60
+ - lib/capistrano/tasks/unicorn.rake
61
+ - lib/capistrano/unicorn.rb
62
+ homepage: https://github.com/ccocchi/capistrano-unicorn-rails
63
+ licenses:
64
+ - MIT
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 1.8.23
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: Basic tasks for starting and stoping Unicorn! servers via capistrano tasks
87
+ test_files: []