capistrano-service 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.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano-bundler.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Capistrano, your one stop deployment shop.
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.
@@ -0,0 +1,73 @@
1
+ # Capistrano::service
2
+
3
+ Define custom service tasks in Capistrano 3.x.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'capistrano', '~> 3.1.0'
11
+ gem 'capistrano-service'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install capistrano-service
21
+
22
+ ## Setup
23
+
24
+ Because this library creates tasks dynamically based on settings you define, setup is a little different than other Capistrano 3.x plugins. Before you require `capistrano/service` in your `Capfile`, you need to define the service you want to setup:
25
+
26
+ ``` ruby
27
+ set :services, [:nginx, :unicorn]
28
+ require 'capistrano/service'
29
+ ```
30
+
31
+ Once you've done this, you'll see that several tasks are defined for each service you added:
32
+
33
+ ``` bash
34
+ $ cap -T
35
+ ...
36
+ cap service:nginx:restart # Restart service: nginx
37
+ cap service:nginx:start # Start service: nginx
38
+ cap service:nginx:status # Status for service: nginx
39
+ cap service:nginx:stop # Stop service: nginx
40
+ cap service:unicorn:restart # Restart service: unicorn
41
+ cap service:unicorn:start # Start service: unicorn
42
+ cap service:unicorn:status # Status for service: unicorn
43
+ cap service:unicorn:stop # Stop service: unicorn
44
+ ```
45
+
46
+ ### Service Roles
47
+
48
+ By default, the service commands that you define will be executed on the `:all` role, however in some circumstances you may wish to only execute a service on specific roles. You can do this by setting `{service_name}_role` before requiring `capistrano/service`.
49
+
50
+ ``` ruby
51
+ set :services, [:nginx, :unicorn]
52
+ set :nginx_roles, :web
53
+ set :unicorn_roles, :app
54
+ require 'capistrano/service'
55
+ ```
56
+
57
+ ## Usage
58
+
59
+ Once you've set everything up, simply call your tasks directly (`cap service:nginx:restart`), or add them to the deploy flow:
60
+
61
+ ``` ruby
62
+ namespace :deploy do
63
+ after :publishing, 'service:nginx:restart', 'service:unicorn:restart'
64
+ end
65
+ ```
66
+
67
+ ## Contributing
68
+
69
+ 1. Fork it
70
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
71
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
72
+ 4. Push to the branch (`git push origin my-new-feature`)
73
+ 5. Create new Pull Request
@@ -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
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'capistrano-service'
7
+ spec.version = '0.0.1'
8
+ spec.authors = ['PJ Kelly']
9
+ spec.email = ['pj@crushlovely.com']
10
+ spec.description = %q{Cleanly manage your Linux services with Capistrano 3.x}
11
+ spec.summary = %q{Cleanly manage your Linux services with Capistrano 3.x}
12
+ spec.homepage = 'https://github.com/crushlovely/capistrano-service'
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_dependency 'capistrano', '>= 3.0.0.pre'
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.3'
23
+ spec.add_development_dependency 'rake'
24
+ end
File without changes
@@ -0,0 +1 @@
1
+ load File.expand_path('../tasks/service.rake', __FILE__)
@@ -0,0 +1,33 @@
1
+ Capistrano::Configuration.env.fetch(:services, []).each do |service|
2
+ namespace :service do
3
+ namespace service do
4
+ desc "Restart service: #{service}"
5
+ Rake::Task.define_task(:restart) do |t|
6
+ on roles fetch(:"#{service}_roles", :all) do
7
+ execute :sudo, :service, service, "restart"
8
+ end
9
+ end
10
+
11
+ desc "Start service: #{service}"
12
+ Rake::Task.define_task(:start) do |t|
13
+ on roles fetch(:"#{service}_roles", :all) do
14
+ execute :sudo, :service, service, "start"
15
+ end
16
+ end
17
+
18
+ desc "Stop service: #{service}"
19
+ Rake::Task.define_task(:stop) do |t|
20
+ on roles fetch(:"#{service}_roles", :all) do
21
+ execute :sudo, :service, service, "stop"
22
+ end
23
+ end
24
+
25
+ desc "Status for service: #{service}"
26
+ Rake::Task.define_task(:status) do |t|
27
+ on roles fetch(:"#{service}_roles", :all) do
28
+ info capture("sudo service #{service} status")
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-service
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - PJ Kelly
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-03-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: capistrano
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 3.0.0.pre
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 3.0.0.pre
30
+ - !ruby/object:Gem::Dependency
31
+ name: bundler
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '1.3'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.3'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: Cleanly manage your Linux services with Capistrano 3.x
63
+ email:
64
+ - pj@crushlovely.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - Gemfile
70
+ - LICENSE
71
+ - README.md
72
+ - Rakefile
73
+ - capistrano-service.gemspec
74
+ - lib/capistrano-service.rb
75
+ - lib/capistrano/service.rb
76
+ - lib/capistrano/tasks/service.rake
77
+ homepage: https://github.com/crushlovely/capistrano-service
78
+ licenses:
79
+ - MIT
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubyforge_project:
98
+ rubygems_version: 1.8.23
99
+ signing_key:
100
+ specification_version: 3
101
+ summary: Cleanly manage your Linux services with Capistrano 3.x
102
+ test_files: []
103
+ has_rdoc: