capistrano-unicorn-tasks 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8a20fed897b076e09a98950bda8cd561bfba449a
4
+ data.tar.gz: 8f3cafdb561885a65c277edc4994b33326529482
5
+ SHA512:
6
+ metadata.gz: 951ceb05a74c7d7200881af7548766e2d55f1e0f7e8d001cc504e385c01a4bfdc3f2c46eb241eb84f4018e8f6088ee1c0f43229a0df5f8180e84e76b56947eac
7
+ data.tar.gz: 552efcb92902d8a0a39540a08d6f906a34de25542b8a36fa641d52dfb7fa8b01f07eca1d7cc8bae778a92559a2601cd30fba241ce757a2400d934b7b7a59c0dc
@@ -0,0 +1,20 @@
1
+ Copyright 2015 kami
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,51 @@
1
+ # Capistrano Unicorn Tasks
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/capistrano-unicorn-tasks.svg)](http://badge.fury.io/rb/capistrano-unicorn-tasks)
4
+
5
+ This gem provides some unicorn tasks for capistrano.
6
+ It just adds three `cap` tasks, `unicorn:start`, `unicorn:stop` and `unicorn:restart`.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'capistrano-unicorn-tasks'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ ```
19
+ $ bundle
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ Add this line to your application's Capfile:
25
+
26
+ ```ruby
27
+ require 'capistrano/unicorn/tasks'
28
+ ```
29
+
30
+ That's it.
31
+ You will be able to use additional `cap` tasks.
32
+
33
+ If you want to restart automatically when deploy with capistrano, add this lines to your `config/deploy.rb`:
34
+
35
+ ```ruby
36
+ namespace :deploy do
37
+ task :restart do
38
+ invoke 'unicorn:restart'
39
+ end
40
+ end
41
+
42
+ after 'deploy:publishing', 'deploy:restart'
43
+ ```
44
+
45
+ ## Contributing
46
+
47
+ 1. Fork it ( https://github.com/kami-zh/capistrano-unicorn-tasks/fork )
48
+ 2. Create your feature branch (git checkout -b my-new-feature)
49
+ 3. Commit your changes (git commit -am 'Add some feature')
50
+ 4. Push to the branch (git push origin my-new-feature)
51
+ 5. Create a new Pull Request
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
File without changes
@@ -0,0 +1 @@
1
+ load File.expand_path('../tasks/unicorn.rake', __FILE__)
@@ -0,0 +1,76 @@
1
+ namespace :load do
2
+ task :defaults do
3
+ set :unicorn_config_path, -> { File.join(current_path, 'config/unicorn.rb') }
4
+ set :unicorn_pid_path, -> { File.join(current_path, 'tmp/pids/unicorn.pid') }
5
+ set :unicorn_roles, -> { :app }
6
+ end
7
+ end
8
+
9
+ namespace :unicorn do
10
+ def start_unicorn
11
+ within current_path do
12
+ info 'Starting Unicorn ...'
13
+ execute :bundle, :exec, :unicorn_rails, "-c #{fetch(:unicorn_config_path)} -E #{fetch(:rails_env)} -D"
14
+ end
15
+ end
16
+
17
+ def stop_unicorn
18
+ info 'Stopping Unicorn ...'
19
+ execute :kill, "-s QUIT #{pid}"
20
+ end
21
+
22
+ def restart_unicorn
23
+ info 'Restarting Unicorn ...'
24
+ execute :kill, "-s USR2 #{pid}"
25
+ end
26
+
27
+ def remove_pid
28
+ info 'Removing pid ...'
29
+ execute :rm, fetch(:unicorn_pid_path)
30
+ end
31
+
32
+ def pid_exists?
33
+ test("[ -e #{fetch(:unicorn_pid_path)} ]")
34
+ end
35
+
36
+ def pid_running?
37
+ test("kill -0 #{pid}")
38
+ end
39
+
40
+ def pid
41
+ "`cat #{fetch(:unicorn_pid_path)}`"
42
+ end
43
+
44
+ desc 'Start Unicorn'
45
+ task :start do
46
+ on roles(fetch(:unicorn_roles)) do
47
+ if pid_exists? && pid_running?
48
+ info 'Unicorn is running ...'
49
+ else
50
+ remove_pid if pid_exists?
51
+
52
+ start_unicorn
53
+ end
54
+ end
55
+ end
56
+
57
+ desc 'Stop Unicorn'
58
+ task :stop do
59
+ on roles(fetch(:unicorn_roles)) do
60
+ if pid_exists?
61
+ pid_running? ? stop_unicorn : remove_pid
62
+ else
63
+ info 'Unicorn is not running ...'
64
+ end
65
+ end
66
+ end
67
+
68
+ desc 'Restart Unicorn'
69
+ task :restart do
70
+ invoke 'unicorn:start'
71
+
72
+ on roles(fetch(:unicorn_roles)) do
73
+ restart_unicorn
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,7 @@
1
+ module Capistrano
2
+ module Unicorn
3
+ module Tasks
4
+ VERSION = '0.1.0'
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-unicorn-tasks
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - kami
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capistrano
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Provides some unicorn tasks for capistrano.
28
+ email:
29
+ - hiroki.zenigami@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - MIT-LICENSE
35
+ - README.md
36
+ - Rakefile
37
+ - lib/capistrano-unicorn-tasks.rb
38
+ - lib/capistrano/unicorn/tasks.rb
39
+ - lib/capistrano/unicorn/tasks/unicorn.rake
40
+ - lib/capistrano/unicorn/tasks/version.rb
41
+ homepage: https://github.com/kami-zh/capistrano-unicorn-tasks
42
+ licenses:
43
+ - MIT
44
+ metadata: {}
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 2.5.1
62
+ signing_key:
63
+ specification_version: 4
64
+ summary: Provides some unicorn tasks for capistrano.
65
+ test_files: []