ey_tools 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +22 -0
- data/README.md +30 -0
- data/bin/ey-console +9 -0
- data/lib/ey_tools.rb +3 -0
- data/lib/ey_tools/base.rb +71 -0
- data/lib/ey_tools/console.rb +34 -0
- data/lib/ey_tools/version.rb +5 -0
- metadata +102 -0
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Andrey Deryabin
|
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,30 @@
|
|
1
|
+
# EY Tools
|
2
|
+
|
3
|
+
Open Rails console in Engine Yard.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'ey_tools'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
~~~ sh
|
14
|
+
$ bundle
|
15
|
+
~~~
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
~~~ sh
|
20
|
+
$ ey-console
|
21
|
+
~~~
|
22
|
+
|
23
|
+
|
24
|
+
## Contributing
|
25
|
+
|
26
|
+
1. Fork it
|
27
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
28
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
29
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
30
|
+
5. Create new Pull Request
|
data/bin/ey-console
ADDED
data/lib/ey_tools.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'engineyard'
|
2
|
+
require 'engineyard/error'
|
3
|
+
require 'engineyard/thor'
|
4
|
+
require 'engineyard/deploy_config'
|
5
|
+
require 'engineyard/serverside_runner'
|
6
|
+
require 'launchy'
|
7
|
+
|
8
|
+
module EY
|
9
|
+
module Tools
|
10
|
+
module CLI
|
11
|
+
class Base < EY::Thor
|
12
|
+
require 'engineyard/cli/recipes'
|
13
|
+
require 'engineyard/cli/web'
|
14
|
+
require 'engineyard/cli/api'
|
15
|
+
require 'engineyard/cli/ui'
|
16
|
+
require 'engineyard/error'
|
17
|
+
require 'engineyard-cloud-client/errors'
|
18
|
+
|
19
|
+
include Thor::Actions
|
20
|
+
|
21
|
+
def self.start(given_args=ARGV, config={})
|
22
|
+
Thor::Base.shell = EY::CLI::UI
|
23
|
+
ui = EY::CLI::UI.new
|
24
|
+
super(given_args, {:shell => ui}.merge(config))
|
25
|
+
rescue EY::Error, EY::CloudClient::Error => e
|
26
|
+
ui.print_exception(e)
|
27
|
+
exit 1
|
28
|
+
rescue Interrupt => e
|
29
|
+
puts
|
30
|
+
ui.print_exception(e)
|
31
|
+
ui.say("Quitting...")
|
32
|
+
raise
|
33
|
+
rescue SystemExit, Errno::EPIPE
|
34
|
+
# don't print a message for safe exits
|
35
|
+
raise
|
36
|
+
rescue Exception => e
|
37
|
+
ui.print_exception(e)
|
38
|
+
raise
|
39
|
+
end
|
40
|
+
|
41
|
+
no_tasks do
|
42
|
+
def ssh_host_filter(opts)
|
43
|
+
return lambda {|instance| true } if opts[:all]
|
44
|
+
return lambda {|instance| %w(solo app app_master ).include?(instance.role) } if opts[:app_servers]
|
45
|
+
return lambda {|instance| %w(solo db_master db_slave).include?(instance.role) } if opts[:db_servers ]
|
46
|
+
return lambda {|instance| %w(solo db_master ).include?(instance.role) } if opts[:db_master ]
|
47
|
+
return lambda {|instance| %w(db_slave ).include?(instance.role) } if opts[:db_slaves ]
|
48
|
+
return lambda {|instance| %w(util).include?(instance.role) && opts[:utilities].include?(instance.name) } if opts[:utilities]
|
49
|
+
return lambda {|instance| %w(solo app_master ).include?(instance.role) }
|
50
|
+
end
|
51
|
+
|
52
|
+
def ssh_hosts(opts, environment)
|
53
|
+
if opts[:utilities] and not opts[:utilities].respond_to?(:include?)
|
54
|
+
includes_everything = []
|
55
|
+
class << includes_everything
|
56
|
+
def include?(*) true end
|
57
|
+
end
|
58
|
+
filter = ssh_host_filter(opts.merge(:utilities => includes_everything))
|
59
|
+
else
|
60
|
+
filter = ssh_host_filter(opts)
|
61
|
+
end
|
62
|
+
|
63
|
+
instances = environment.instances.select {|instance| filter[instance] }
|
64
|
+
raise NoInstancesError.new(environment.name) if instances.empty?
|
65
|
+
return instances.map { |instance| instance.public_hostname }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'ey_tools/base'
|
2
|
+
|
3
|
+
module EY
|
4
|
+
module Tools
|
5
|
+
module Console
|
6
|
+
class CLI < EY::Tools::CLI::Base
|
7
|
+
default_task :console
|
8
|
+
|
9
|
+
desc "console [--environment ENVIRONMENT]", "Open Rails console in environment."
|
10
|
+
|
11
|
+
long_desc <<-DESC
|
12
|
+
This command must be run Rails console based on settings in your ey.yml file.
|
13
|
+
DESC
|
14
|
+
method_option :environment, :type => :string, :aliases => %w(-e),
|
15
|
+
:required => true, :default => false,
|
16
|
+
:desc => "Environment in which to deploy this application"
|
17
|
+
|
18
|
+
def console
|
19
|
+
app_env = fetch_app_environment(options[:app], options[:environment], options[:account])
|
20
|
+
|
21
|
+
hosts = ssh_hosts(options, app_env.environment)
|
22
|
+
|
23
|
+
raise NoCommandError.new if hosts.size != 1
|
24
|
+
|
25
|
+
exits = hosts.map do |host|
|
26
|
+
system Escape.shell_command(['ssh', '-t', "#{app_env.environment.username}@#{host}", "cd /data/#{app_env.app.name}/current; RAILS_ENV=production bundle exec rails c"].compact)
|
27
|
+
$?.exitstatus
|
28
|
+
end
|
29
|
+
exit exits.detect {|status| !status.zero?} || 0
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ey_tools
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Andrey Deryabin
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: engineyard
|
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: 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: Extension for EY for rails developers
|
63
|
+
email:
|
64
|
+
- deriabin@gmail.com
|
65
|
+
executables:
|
66
|
+
- ey-console
|
67
|
+
extensions: []
|
68
|
+
extra_rdoc_files: []
|
69
|
+
files:
|
70
|
+
- bin/ey-console
|
71
|
+
- lib/ey_tools/base.rb
|
72
|
+
- lib/ey_tools/console.rb
|
73
|
+
- lib/ey_tools/version.rb
|
74
|
+
- lib/ey_tools.rb
|
75
|
+
- LICENSE.txt
|
76
|
+
- README.md
|
77
|
+
homepage: ''
|
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: Extension for EY for rails developers
|
102
|
+
test_files: []
|