unicap 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 02bb77bbdd132b0f3bfe4a36201e55ad3253573a
4
+ data.tar.gz: 39bef985512224c08d19f414f3ef8cef38d07988
5
+ SHA512:
6
+ metadata.gz: 550421706302f1f7b6eb590fd52dc7dc0ed86fb763f83379688135634617f42cf5e5d71fd8e80c3fe16c5b5452b60f44d7385658c1d4de0c12e9a0e3ef7fad4d
7
+ data.tar.gz: b73d2f3a65112eec3e97133eabe35bbd8ddba3d9fd130ad6df6ae8e53c805d3806d64d266eaf2f4695fe8e206d8bd00d5cd2ab837a5fa3c3f29a4831ef8171b5
data/MIT-LICENSE ADDED
@@ -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.
data/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # Unicap
2
+
3
+ Unicap is capistrano tasks for unicorn with Rails application.
4
+ It just adds three `cap` tasks, `unicorn:start`, `unicorn:stop` and `unicorn:restart`.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'unicap'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ ```
17
+ $ bundle
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ Add this line to your application's Capfile:
23
+
24
+ ```ruby
25
+ require 'unicap'
26
+ ```
27
+
28
+ That's it.
29
+ You will be able to use additional `cap` tasks.
30
+
31
+ If you want to restart automatically when deploy with capistrano, add this lines to your `config/deploy.rb`:
32
+
33
+ ```ruby
34
+ namespace :deploy do
35
+ task :restart do
36
+ invoke 'unicorn:restart'
37
+ end
38
+
39
+ after :publishing, :restart
40
+ end
41
+ ```
42
+
43
+ ## Contributing
44
+
45
+ 1. Fork it ( https://github.com/kami30k/unicap/fork )
46
+ 2. Create your feature branch (git checkout -b my-new-feature)
47
+ 3. Commit your changes (git commit -am 'Add some feature')
48
+ 4. Push to the branch (git push origin my-new-feature)
49
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,76 @@
1
+ namespace :load do
2
+ task :defaults do
3
+ set :unicorn_config, -> { File.join(current_path, 'config/unicorn.rb') }
4
+ set :unicorn_pid, -> { 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)} -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)
30
+ end
31
+
32
+ def pid_exists?
33
+ test("[ -e #{fetch(:unicorn_pid)} ]")
34
+ end
35
+
36
+ def pid_running?
37
+ test("kill -0 #{pid}")
38
+ end
39
+
40
+ def pid
41
+ "`cat #{fetch(:unicorn_pid)}`"
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,3 @@
1
+ module Unicap
2
+ VERSION = '0.0.1'
3
+ end
data/lib/unicap.rb ADDED
@@ -0,0 +1 @@
1
+ load File.expand_path('../unicap/tasks/unicap.rake', __FILE__)
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: unicap
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - kami
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-24 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: Capistrano tasks for unicorn with Rails application.
28
+ email:
29
+ - kami30k@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - MIT-LICENSE
35
+ - README.md
36
+ - Rakefile
37
+ - lib/unicap.rb
38
+ - lib/unicap/tasks/unicap.rake
39
+ - lib/unicap/version.rb
40
+ homepage: https://github.com/kami30k/unicap
41
+ licenses:
42
+ - MIT
43
+ metadata: {}
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubyforge_project:
60
+ rubygems_version: 2.2.2
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: Capistrano tasks for unicorn with Rails application.
64
+ test_files: []