capistrano-extras 0.1.0
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/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +41 -0
- data/Rakefile +1 -0
- data/capistrano-extras.gemspec +25 -0
- data/lib/capistrano/extras/version.rb +5 -0
- data/lib/capistrano/extras.rb +4 -0
- data/lib/capistrano/tasks/console.rake +11 -0
- data/lib/capistrano/tasks/logs.rake +13 -0
- data/lib/capistrano/utils/utils.rb +30 -0
- metadata +106 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Balazs Kovacs
|
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,41 @@
|
|
1
|
+
# Capistrano::Extras
|
2
|
+
|
3
|
+
Capistrano tasks for interactive console and log tailing.
|
4
|
+
|
5
|
+
The gem works only with Capistrano 3!
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'capistrano-extras'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install capistrano-extras
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Add to your Capfile:
|
24
|
+
|
25
|
+
require 'capistrano/extras'
|
26
|
+
|
27
|
+
Run the `bin/console` executable in your `current_path`:
|
28
|
+
|
29
|
+
cap <environment> console
|
30
|
+
|
31
|
+
Tail the logs from the `log` directory (you can pick a file):
|
32
|
+
|
33
|
+
cap <environment> log
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
|
37
|
+
1. Fork it ( http://github.com/jbslabs/capistrano-extras/fork )
|
38
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
39
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
40
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
41
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'capistrano/extras/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'capistrano-extras'
|
8
|
+
spec.version = Capistrano::Extras::VERSION
|
9
|
+
spec.authors = ['Balazs Kovacs']
|
10
|
+
spec.email = ['balazs.kovacs@supercharge.io']
|
11
|
+
spec.summary = 'Capistrano tasks for interactive console and log tailing.'
|
12
|
+
spec.description = ''
|
13
|
+
spec.homepage = ''
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'capistrano', '>= 3.1'
|
22
|
+
spec.add_dependency 'sshkit', '>= 1.2.0'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'rake'
|
25
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
namespace :console do
|
2
|
+
desc 'Runs a console interactively with "bin/console" executable'
|
3
|
+
task :interactive do
|
4
|
+
on roles(:app), primary: true do |host|
|
5
|
+
env = fetch(:stage)
|
6
|
+
execute_interactively host, "cd #{current_path} && RACK_ENV=#{env} bin/console"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
task :console => ['console:interactive']
|
@@ -0,0 +1,13 @@
|
|
1
|
+
namespace :logs do
|
2
|
+
desc 'Tails a log file from the "log" directory'
|
3
|
+
task :tail do
|
4
|
+
on roles(:app), primary: true do |host|
|
5
|
+
logfile = pick_file('log')
|
6
|
+
|
7
|
+
puts "\n----- Tailing log/#{logfile} -----\n\n"
|
8
|
+
execute_interactively host, "cd #{current_path} && tail -f log/#{logfile}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
task :logs => ['logs:tail']
|
@@ -0,0 +1,30 @@
|
|
1
|
+
## Pick a file from its directory
|
2
|
+
def pick_file(directory)
|
3
|
+
# parse files
|
4
|
+
file_names = capture("cd #{current_path} && ls -1 #{directory}").split("\n")
|
5
|
+
files = file_names.map.with_index { |f, i| [i, f] }.to_h
|
6
|
+
file_options = files.map { |i, f| " #{i} - #{f}" }.join("\n")
|
7
|
+
|
8
|
+
index = -1
|
9
|
+
|
10
|
+
# pick an index
|
11
|
+
loop do
|
12
|
+
ask(:index, "\n#{file_options}\n")
|
13
|
+
index = Integer fetch(:index) rescue nil
|
14
|
+
|
15
|
+
break if files.key?(index)
|
16
|
+
end
|
17
|
+
|
18
|
+
# return filename
|
19
|
+
files[index]
|
20
|
+
end
|
21
|
+
|
22
|
+
## Execute a command on a given host
|
23
|
+
def execute_interactively(host, command)
|
24
|
+
user = host.user
|
25
|
+
hostname = host.hostname
|
26
|
+
port = host.port || 22
|
27
|
+
|
28
|
+
# execute in shell
|
29
|
+
exec "ssh -l #{user} #{hostname} -p #{port} -t '#{command}'"
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-extras
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Balazs Kovacs
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-04-01 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.1'
|
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.1'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: sshkit
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.2.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: 1.2.0
|
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: ''
|
63
|
+
email:
|
64
|
+
- balazs.kovacs@supercharge.io
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- Gemfile
|
71
|
+
- LICENSE.txt
|
72
|
+
- README.md
|
73
|
+
- Rakefile
|
74
|
+
- capistrano-extras.gemspec
|
75
|
+
- lib/capistrano/extras.rb
|
76
|
+
- lib/capistrano/extras/version.rb
|
77
|
+
- lib/capistrano/tasks/console.rake
|
78
|
+
- lib/capistrano/tasks/logs.rake
|
79
|
+
- lib/capistrano/utils/utils.rb
|
80
|
+
homepage: ''
|
81
|
+
licenses:
|
82
|
+
- MIT
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ! '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
requirements: []
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 1.8.28
|
102
|
+
signing_key:
|
103
|
+
specification_version: 3
|
104
|
+
summary: Capistrano tasks for interactive console and log tailing.
|
105
|
+
test_files: []
|
106
|
+
has_rdoc:
|