capistrano-unicorn 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +41 -0
- data/Gemfile +3 -0
- data/README.md +44 -0
- data/capistrano-unicorn.gemspec +19 -0
- data/lib/capistrano-unicorn/capistrano_integration.rb +77 -0
- data/lib/capistrano-unicorn/version.rb +5 -0
- data/lib/capistrano-unicorn.rb +2 -0
- metadata +62 -0
data/.gitignore
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
!.gitignore
|
2
|
+
*.gem
|
3
|
+
*.rbc
|
4
|
+
*.sw[a-p]
|
5
|
+
*.tmproj
|
6
|
+
*.tmproject
|
7
|
+
*.un~
|
8
|
+
*~
|
9
|
+
.DS_Store
|
10
|
+
.Spotlight-V100
|
11
|
+
.Trashes
|
12
|
+
._*
|
13
|
+
.bundle
|
14
|
+
.config
|
15
|
+
.directory
|
16
|
+
.elc
|
17
|
+
.redcar
|
18
|
+
.yardoc
|
19
|
+
/.emacs.desktop
|
20
|
+
/.emacs.desktop.lock
|
21
|
+
Desktop.ini
|
22
|
+
Gemfile.lock
|
23
|
+
Icon?
|
24
|
+
InstalledFiles
|
25
|
+
Session.vim
|
26
|
+
Thumbs.db
|
27
|
+
\#*\#
|
28
|
+
_yardoc
|
29
|
+
auto-save-list
|
30
|
+
coverage
|
31
|
+
doc/
|
32
|
+
lib/bundler/man
|
33
|
+
pkg
|
34
|
+
pkg/*
|
35
|
+
rdoc
|
36
|
+
spec/reports
|
37
|
+
test/tmp
|
38
|
+
test/version_tmp
|
39
|
+
tmp
|
40
|
+
tmtags
|
41
|
+
tramp
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# Capistrano Unicorn
|
2
|
+
|
3
|
+
Capistrano plugin that integrates Unicorn tasks into deployment script.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```
|
8
|
+
gem install capistrano-unicorn
|
9
|
+
```
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
Add unicorn plugin into your deploy.rb file.
|
14
|
+
|
15
|
+
**NOTE:** Should be placed after all hooks
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
require 'capistrano-unicorn'
|
19
|
+
```
|
20
|
+
|
21
|
+
Place configuration file into ```config/unicorn/YOUR_ENV.rb```
|
22
|
+
|
23
|
+
To test if it works type:
|
24
|
+
|
25
|
+
```
|
26
|
+
cap unicorn:start
|
27
|
+
cap unicorn:stop
|
28
|
+
cap unicorn:reload
|
29
|
+
```
|
30
|
+
|
31
|
+
## Configuration options
|
32
|
+
|
33
|
+
- unicorn_env — Set unicorn environment. Default to "rails_env" variable.
|
34
|
+
- unicorn_pid — Set unicorn PID file path. Default to "current_path/tmp/pids/unicorn.pid"
|
35
|
+
|
36
|
+
## License
|
37
|
+
|
38
|
+
Copyright © 2011 Dan Sosedoff.
|
39
|
+
|
40
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
41
|
+
|
42
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
43
|
+
|
44
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/capistrano-unicorn/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = 'capistrano-unicorn'
|
6
|
+
gem.version = CapistranoUnicorn::VERSION.dup
|
7
|
+
gem.author = 'Dan Sosedoff'
|
8
|
+
gem.email = 'dan.sosedoff@gmail.com'
|
9
|
+
gem.homepage = 'https://github.com/sosedoff/capistrano-unicorn'
|
10
|
+
gem.summary = %q{Unicorn integration for Capistrano}
|
11
|
+
gem.description = %q{Capistrano plugin that integrates Unicorn server tasks.}
|
12
|
+
|
13
|
+
gem.files = `git ls-files`.split("\n")
|
14
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
|
16
|
+
gem.require_paths = ['lib']
|
17
|
+
|
18
|
+
gem.add_runtime_dependency 'capistrano'
|
19
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'capistrano'
|
2
|
+
require 'capistrano/version'
|
3
|
+
|
4
|
+
module CapistranoUnicorn
|
5
|
+
class CapistranoIntegration
|
6
|
+
def self.load_into(capistrano_config)
|
7
|
+
capistrano_config.load do
|
8
|
+
|
9
|
+
# Check if remote file exists
|
10
|
+
#
|
11
|
+
def remote_file_exists?(full_path)
|
12
|
+
'true' == capture("if [ -e #{full_path} ]; then echo 'true'; fi").strip
|
13
|
+
end
|
14
|
+
|
15
|
+
# Set unicorn vars
|
16
|
+
#
|
17
|
+
_cset(:unicorn_pid, "#{fetch(:current_path)}/tmp/pids/unicorn.pid")
|
18
|
+
_cset(:unicorn_env, (fetch(:rails_env) rescue 'production'))
|
19
|
+
|
20
|
+
namespace :unicorn do
|
21
|
+
desc 'Start Unicorn'
|
22
|
+
task :start, :roles => :app, :except => {:no_release => true} do
|
23
|
+
config_path = "#{current_path}/config/unicorn/#{unicorn_env}.rb"
|
24
|
+
if remote_file_exists?(config_path)
|
25
|
+
logger.important("Starting...")
|
26
|
+
run "cd #{current_path} && bundle exec unicorn_rails -c #{config_path} -E #{unicorn_env} -D"
|
27
|
+
else
|
28
|
+
logger.important("Config file for \"#{unicorn_env}\" environment was not found at \"#{config_path}\"", "Unicorn")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'Stop Unicorn'
|
33
|
+
task :stop, :roles => :app, :except => {:no_release => true} do
|
34
|
+
if remote_file_exists?(unicorn_pid)
|
35
|
+
logger.important("Stopping...", "Unicorn")
|
36
|
+
run "#{try_sudo} kill `cat #{unicorn_pid}`"
|
37
|
+
else
|
38
|
+
logger.important("No PIDs found. Check if unicorn is running.", "Unicorn")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
desc 'Unicorn graceful shutdown'
|
43
|
+
task :graceful_stop, :roles => :app, :except => {:no_release => true} do
|
44
|
+
if remote_file_exists?(unicorn_pid)
|
45
|
+
logger.important("Stopping...", "Unicorn")
|
46
|
+
run "#{try_sudo} kill -s QUIT `cat #{unicorn_pid}`"
|
47
|
+
else
|
48
|
+
logger.important("No PIDs found. Check if unicorn is running.", "Unicorn")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
desc 'Reload Unicorn'
|
53
|
+
task :reload, :roles => :app, :except => {:no_release => true} do
|
54
|
+
if remote_file_exists?(unicorn_pid)
|
55
|
+
logger.important("Stopping...", "Unicorn")
|
56
|
+
run "#{try_sudo} kill -s USR2 `cat #{unicorn_pid}`"
|
57
|
+
else
|
58
|
+
logger.important("No PIDs found. Starting Unicorn server...", "Unicorn")
|
59
|
+
config_path = "#{current_path}/config/unicorn/#{unicorn_env}.rb"
|
60
|
+
if remote_file_exists?(config_path)
|
61
|
+
run "cd #{current_path} && bundle exec unicorn_rails -c #{config_path} -E #{unicorn_env} -D"
|
62
|
+
else
|
63
|
+
logger.important("Config file for \"#{unicorn_env}\" environment was not found at \"#{config_path}\"", "Unicorn")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
after "deploy:restart", "unicorn:reload"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
if Capistrano::Configuration.instance
|
76
|
+
CapistranoUnicorn::CapistranoIntegration.load_into(Capistrano::Configuration.instance)
|
77
|
+
end
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-unicorn
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Dan Sosedoff
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-10-11 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: capistrano
|
16
|
+
requirement: &2154378720 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2154378720
|
25
|
+
description: Capistrano plugin that integrates Unicorn server tasks.
|
26
|
+
email: dan.sosedoff@gmail.com
|
27
|
+
executables: []
|
28
|
+
extensions: []
|
29
|
+
extra_rdoc_files: []
|
30
|
+
files:
|
31
|
+
- .gitignore
|
32
|
+
- Gemfile
|
33
|
+
- README.md
|
34
|
+
- capistrano-unicorn.gemspec
|
35
|
+
- lib/capistrano-unicorn.rb
|
36
|
+
- lib/capistrano-unicorn/capistrano_integration.rb
|
37
|
+
- lib/capistrano-unicorn/version.rb
|
38
|
+
homepage: https://github.com/sosedoff/capistrano-unicorn
|
39
|
+
licenses: []
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
requirements: []
|
57
|
+
rubyforge_project:
|
58
|
+
rubygems_version: 1.8.6
|
59
|
+
signing_key:
|
60
|
+
specification_version: 3
|
61
|
+
summary: Unicorn integration for Capistrano
|
62
|
+
test_files: []
|