capistrano-progress 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +20 -0
- data/README.md +39 -0
- data/lib/capistrano-progress.rb +6 -0
- data/lib/capistrano/progress.rb +9 -0
- data/lib/capistrano/progress/configuration/actions/progress.rb +65 -0
- data/lib/capistrano/progress/parallel_status.rb +38 -0
- data/lib/capistrano/progress/server_with_roles.rb +17 -0
- metadata +170 -0
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Piotr Banasik
|
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,39 @@
|
|
1
|
+
# capistrano-progress
|
2
|
+
|
3
|
+
Adds a new command run\_with\_progress, simillar to run, which will
|
4
|
+
display a (ascii) graphical progress of each server running the command
|
5
|
+
|
6
|
+
## Example
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
require 'capistrano-progress'
|
10
|
+
|
11
|
+
set :user, "vagrant"
|
12
|
+
|
13
|
+
role :foo, "1.localhost.tv:2222"
|
14
|
+
role :foo, "2.localhost.tv:2222"
|
15
|
+
role :foo, "3.localhost.tv:2222"
|
16
|
+
role :foo, "4.localhost.tv:2222"
|
17
|
+
role :foo, "5.localhost.tv:2222"
|
18
|
+
role :foo, "6.localhost.tv:2222"
|
19
|
+
|
20
|
+
task :foo, :roles => [:foo] do
|
21
|
+
run_with_progress "/opt/vagrant_ruby/bin/ruby -e 'sleep rand(10)'"
|
22
|
+
end
|
23
|
+
```
|
24
|
+
|
25
|
+
## Contributing to capistrano-progress
|
26
|
+
|
27
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
28
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
29
|
+
* Fork the project.
|
30
|
+
* Start a feature/bugfix branch.
|
31
|
+
* Commit and push until you are happy with your contribution.
|
32
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
33
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
34
|
+
|
35
|
+
## Copyright
|
36
|
+
|
37
|
+
Copyright (c) 2013 Piotr Banasik. See LICENSE.txt for
|
38
|
+
further details.
|
39
|
+
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require_relative 'progress/parallel_status'
|
2
|
+
require_relative 'progress/server_with_roles'
|
3
|
+
require_relative 'progress/configuration/actions/progress'
|
4
|
+
|
5
|
+
require 'capistrano'
|
6
|
+
|
7
|
+
class Capistrano::Configuration
|
8
|
+
include Capistrano::Progress::Configuration::Actions::Progress
|
9
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module Capistrano
|
2
|
+
module Progress
|
3
|
+
module Configuration
|
4
|
+
module Actions
|
5
|
+
module Progress
|
6
|
+
|
7
|
+
def run_without_progress(cmd, options = {}, &block)
|
8
|
+
if options[:eof].nil? && !cmd.include?(sudo)
|
9
|
+
options = options.merge(:eof => !block_given?)
|
10
|
+
end
|
11
|
+
block ||= self.class.default_io_proc
|
12
|
+
tree = Command::Tree.new(self) do |t| t.else(cmd, &block) end
|
13
|
+
run_tree(tree, options)
|
14
|
+
end
|
15
|
+
|
16
|
+
def run(cmd, options = {}, &block)
|
17
|
+
if @run_with_progress
|
18
|
+
servers = find_servers_for_task(current_task).map { |server|
|
19
|
+
ServerWithRoles.new(server, role_names_for_host(server))
|
20
|
+
}
|
21
|
+
status = ParallelStatus.new(servers)
|
22
|
+
logger_level(Capistrano::Logger::IMPORTANT) do
|
23
|
+
status.block do
|
24
|
+
parallelize do |session|
|
25
|
+
servers.each do |server|
|
26
|
+
session.run do
|
27
|
+
status.step server, "Executing ..."
|
28
|
+
run_without_progress cmd, options.merge(:hosts => server), &block
|
29
|
+
status.step server, "Done"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
else
|
36
|
+
run_without_progress cmd, options, &block
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def enable_run_progress
|
41
|
+
@run_with_progress = true
|
42
|
+
end
|
43
|
+
|
44
|
+
def disable_run_progress
|
45
|
+
@run_with_progress = false
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def logger_level(level)
|
51
|
+
old_level = logger.level
|
52
|
+
begin
|
53
|
+
logger.level = level
|
54
|
+
yield
|
55
|
+
ensure
|
56
|
+
logger.level = old_level
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
class ParallelStatus
|
2
|
+
|
3
|
+
def initialize(servers)
|
4
|
+
@statuses = {}
|
5
|
+
servers.each { |server|
|
6
|
+
@statuses[server] = "-"
|
7
|
+
}
|
8
|
+
end
|
9
|
+
|
10
|
+
def step(server, message)
|
11
|
+
@statuses[server] = message
|
12
|
+
Thread.exclusive do
|
13
|
+
clear
|
14
|
+
render
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def render
|
19
|
+
table = Terminal::Table.new :headings => ["Server", "Roles", "Status"]
|
20
|
+
@statuses.each do |server,message|
|
21
|
+
table << [server.to_s, server.roles_string, message]
|
22
|
+
end
|
23
|
+
puts table
|
24
|
+
end
|
25
|
+
|
26
|
+
def clear
|
27
|
+
count = @statuses.keys.length + 4
|
28
|
+
count.times do
|
29
|
+
print "\e[1A\e[K"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def block
|
34
|
+
render
|
35
|
+
yield
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-progress
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Piotr Banasik
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-06-07 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: '0'
|
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: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: cap-ext-parallelize
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: terminal-table
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
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
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: debugger
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: minitest
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: bundler
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: jeweler
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
description: ! "\n Adds a new command run_with_progress which shows a table of
|
127
|
+
all the servers which\n run this command and the progress on each one\n "
|
128
|
+
email: piotr.banasik@gmail.com
|
129
|
+
executables: []
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files:
|
132
|
+
- LICENSE.txt
|
133
|
+
- README.md
|
134
|
+
files:
|
135
|
+
- lib/capistrano-progress.rb
|
136
|
+
- lib/capistrano/progress.rb
|
137
|
+
- lib/capistrano/progress/configuration/actions/progress.rb
|
138
|
+
- lib/capistrano/progress/parallel_status.rb
|
139
|
+
- lib/capistrano/progress/server_with_roles.rb
|
140
|
+
- LICENSE.txt
|
141
|
+
- README.md
|
142
|
+
homepage: http://github.com/piotrb/capistrano-progress
|
143
|
+
licenses:
|
144
|
+
- MIT
|
145
|
+
post_install_message:
|
146
|
+
rdoc_options: []
|
147
|
+
require_paths:
|
148
|
+
- lib
|
149
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
150
|
+
none: false
|
151
|
+
requirements:
|
152
|
+
- - ! '>='
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
segments:
|
156
|
+
- 0
|
157
|
+
hash: -3255057953620990578
|
158
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
|
+
none: false
|
160
|
+
requirements:
|
161
|
+
- - ! '>='
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '0'
|
164
|
+
requirements: []
|
165
|
+
rubyforge_project:
|
166
|
+
rubygems_version: 1.8.25
|
167
|
+
signing_key:
|
168
|
+
specification_version: 3
|
169
|
+
summary: Per-server summaries of how 'run' commands are doing
|
170
|
+
test_files: []
|