capistrano-runit-rake 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +59 -0
- data/Rakefile +2 -0
- data/capistrano-runit-rake.gemspec +23 -0
- data/lib/capistrano-runit-rake.rb +0 -0
- data/lib/capistrano/runit/rake.rb +3 -0
- data/lib/capistrano/tasks/rake.rake +101 -0
- metadata +98 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 56faf6196589befa57ee5337eb7741f0adc9fd91
|
4
|
+
data.tar.gz: 1b2e1e8fb2b6fb2547583b25d01826d9c4877624
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 351073e530f35a3a078ba8e36dff3a8b335ded1e29503944b5c74c8a897cde35110c21f04451fabaf6dd0ac3b8ef79662d8a5f0f2cbdf19e1bc7319a5d65319d
|
7
|
+
data.tar.gz: 1c85e1652b4c16e188c1ac3f6ea4b77ee35497bfb13b79cb08fc1340a32b391f36e33a765baedaaf04bb893c7b5965bf78fd3b05fb46e78d155769606738599e
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Alexander Simonov
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# capistrano-runit-rake
|
2
|
+
|
3
|
+
Capistrano3 tasks for manage long running rake tasks or daemons via runit supervisor.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'capistrano-runit-rake'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install capistrano-runit-rake
|
20
|
+
|
21
|
+
## Tasks
|
22
|
+
|
23
|
+
* `runit:rake:start` -- start all rake tasks.
|
24
|
+
* `runit:rake:stop` -- stop all rake tasks.
|
25
|
+
* `runit:rake:restart` -- restart all rake tasks.
|
26
|
+
* `runit:rake:foo:setup` -- setup `foo` rake task service.
|
27
|
+
* `runit:rake:foo:enable` -- enable `foo` rake task service.
|
28
|
+
* `runit:rake:foo:disable` -- disable `foo` rake task service.
|
29
|
+
* `runit:rake:foo:start` -- start `foo` rake task service.
|
30
|
+
* `runit:rake:foo:stop` -- stop `foo` rake task service.
|
31
|
+
|
32
|
+
## Variables
|
33
|
+
|
34
|
+
* `runit_rake_role` -- what host roles uses runit to run rake long running tasks. Default value: `:app`
|
35
|
+
* `runit_rake_foo_role` -- what host roles uses runit to run rake long running task with key `foo`. Default value: `:app`
|
36
|
+
* `runit_rake_tasks` -- Hash of rake tasks. Default value: `{}`
|
37
|
+
|
38
|
+
## Usage
|
39
|
+
|
40
|
+
Add this line in `Capfile`:
|
41
|
+
```ruby
|
42
|
+
require 'capistrano/runit/rake'
|
43
|
+
```
|
44
|
+
Add your tasks in `config/deploy.rb`:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
set :runit_rake_tasks, {
|
48
|
+
'foo' => 'daemon:bar'
|
49
|
+
}
|
50
|
+
set :runit_rake_foo_role, :db # change role for foo rake task
|
51
|
+
```
|
52
|
+
|
53
|
+
## Contributing
|
54
|
+
|
55
|
+
1. Fork it ( https://github.com/capistrano-runit/rake/fork )
|
56
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
57
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
58
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
59
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
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-runit-rake"
|
7
|
+
spec.version = '0.2.0'
|
8
|
+
spec.authors = ["Alexander Simonov"]
|
9
|
+
spec.email = ["alex@simonov.me"]
|
10
|
+
spec.summary = %q{Capistrano3 tasks for manage long running rake tasks or daemons via runit supervisor.}
|
11
|
+
spec.description = %q{Capistrano3 tasks for manage long running rake tasks or daemons via runit supervisor.}
|
12
|
+
spec.homepage = "https://github.com/capistrano-runit/rake"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
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_development_dependency "bundler", "~> 1.7"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
spec.add_runtime_dependency 'capistrano-runit-core', '~> 0.2.0'
|
23
|
+
end
|
File without changes
|
@@ -0,0 +1,101 @@
|
|
1
|
+
include ::Capistrano::Runit
|
2
|
+
|
3
|
+
namespace :load do
|
4
|
+
task :defaults do
|
5
|
+
set :runit_rake_run_template, nil
|
6
|
+
set :runit_rake_default_hooks, -> { true }
|
7
|
+
set :runit_rake_role, -> { :app }
|
8
|
+
set :runit_rake_tasks, -> { {} }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
namespace :deploy do
|
13
|
+
before :starting, :runit_check_rake_hooks do
|
14
|
+
invoke 'runit:rake:add_default_hooks' if fetch(:runit_rake_default_hooks)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
namespace :runit do
|
19
|
+
namespace :rake do |rake_namespace|
|
20
|
+
# Helpers
|
21
|
+
def collect_rake_run_command(task)
|
22
|
+
array = []
|
23
|
+
array << env_variables
|
24
|
+
array << "RAILS_ENV=#{fetch(:rails_env)}"
|
25
|
+
array << "exec #{SSHKit.config.command_map[:rake]} #{task}"
|
26
|
+
array.compact.join(' ')
|
27
|
+
end
|
28
|
+
|
29
|
+
def generate_namespace_for_rake_task(name, task_name, parent_task)
|
30
|
+
my_namespace = "runit:rake:#{name}"
|
31
|
+
parent_task.application.define_task Rake::Task, "#{my_namespace}:setup" do
|
32
|
+
setup_service("rake_#{name}", collect_rake_run_command(task_name))
|
33
|
+
end
|
34
|
+
parent_task.application.define_task Rake::Task, "#{my_namespace}:enable" do
|
35
|
+
enable_service("rake_#{name}")
|
36
|
+
end
|
37
|
+
parent_task.application.define_task Rake::Task, "#{my_namespace}:disable" do
|
38
|
+
disable_service("rake_#{name}")
|
39
|
+
end
|
40
|
+
parent_task.application.define_task Rake::Task, "#{my_namespace}:start" do
|
41
|
+
start_service("rake_#{name}")
|
42
|
+
end
|
43
|
+
parent_task.application.define_task Rake::Task, "#{my_namespace}:stop" do
|
44
|
+
on roles fetch("runit_rake_#{name}_role".to_sym) do
|
45
|
+
runit_execute_command("rake_#{name}", 'down')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
parent_task.application.define_task Rake::Task, "#{my_namespace}:restart" do
|
49
|
+
restart_service("rake_#{name}")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
task :add_default_hooks do
|
54
|
+
after 'deploy:check', 'runit:rake:check'
|
55
|
+
after 'deploy:updated', 'runit:rake:stop'
|
56
|
+
after 'deploy:reverted', 'runit:rake:stop'
|
57
|
+
after 'deploy:published', 'runit:rake:start'
|
58
|
+
end
|
59
|
+
|
60
|
+
task :hook do |task|
|
61
|
+
fetch(:runit_rake_tasks).each do |key, value|
|
62
|
+
name = key.gsub(/\s*[^A-Za-z0-9\.\-]\s*/, '_')
|
63
|
+
set "runit_rake_#{name}_role".to_sym, -> { :app }
|
64
|
+
generate_namespace_for_rake_task(name, value, task)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
task :check do
|
69
|
+
fetch(:runit_rake_tasks).each do |key, value|
|
70
|
+
name = key.gsub(/\s*[^A-Za-z0-9\.\-]\s*/, '_')
|
71
|
+
check_service('rake', name)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
task :stop do
|
76
|
+
fetch(:runit_rake_tasks).each do |key, value|
|
77
|
+
name = key.gsub(/\s*[^A-Za-z0-9\.\-]\s*/, '_')
|
78
|
+
::Rake::Task["runit:rake:#{name}:stop"].invoke
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
task :start do
|
83
|
+
fetch(:runit_rake_tasks).each do |key, value|
|
84
|
+
name = key.gsub(/\s*[^A-Za-z0-9\.\-]\s*/, '_')
|
85
|
+
::Rake::Task["runit:rake:#{name}:start"].invoke
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
task :restart do
|
90
|
+
fetch(:runit_rake_tasks).each do |key, value|
|
91
|
+
name = key.gsub(/\s*[^A-Za-z0-9\.\-]\s*/, '_')
|
92
|
+
::Rake::Task["runit:rake:#{name}:restart"].invoke
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
Capistrano::DSL.stages.each do |stage|
|
100
|
+
after stage, 'runit:rake:hook'
|
101
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-runit-rake
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexander Simonov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: capistrano-runit-core
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.2.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.2.0
|
55
|
+
description: Capistrano3 tasks for manage long running rake tasks or daemons via runit
|
56
|
+
supervisor.
|
57
|
+
email:
|
58
|
+
- alex@simonov.me
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- capistrano-runit-rake.gemspec
|
69
|
+
- lib/capistrano-runit-rake.rb
|
70
|
+
- lib/capistrano/runit/rake.rb
|
71
|
+
- lib/capistrano/tasks/rake.rake
|
72
|
+
homepage: https://github.com/capistrano-runit/rake
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.4.6
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Capistrano3 tasks for manage long running rake tasks or daemons via runit
|
96
|
+
supervisor.
|
97
|
+
test_files: []
|
98
|
+
has_rdoc:
|