meroku 2.0.23 → 2.0.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +13 -0
- data/README.md +1 -2
- data/lib/meroku/aws.rb +19 -13
- data/lib/meroku/cli.rb +14 -4
- data/lib/meroku/error.rb +1 -2
- data/lib/meroku/node.rb +1 -1
- data/lib/meroku/options.rb +16 -2
- data/lib/meroku/user.rb +49 -8
- data/lib/meroku/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f904e491e3b5db4cac84dd8df856e3f261ed524
|
4
|
+
data.tar.gz: 50bc9918fee760e9023221be2ea2331fc4e3a515
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd05e025fb8078879f8950ce154d9d2b5d775f5f76cb1cb53aba11c1a6006cf750d5d8b9220eb2390ddc3f3e230b254ff84b831e9f4aa59e1da1e170f50e99a6
|
7
|
+
data.tar.gz: 38c5f3b0051a55eca784dc970ff02f1e250b7a3f6d7ae5124ac27955c3f5ad40d1d598c8c58a9616ad942a563934af417dd886ffd5c3ce0bfb028972de25c08b
|
data/.travis.yml
CHANGED
@@ -3,3 +3,16 @@ language: ruby
|
|
3
3
|
rvm:
|
4
4
|
- 2.4.2
|
5
5
|
before_install: gem install bundler -v 1.15.4
|
6
|
+
|
7
|
+
env:
|
8
|
+
global:
|
9
|
+
- CC_TEST_REPORTER_ID=61d42f990728bb450857fbd8b1f09d650f929f086d0d2d7d0c13ead9d33b77e2
|
10
|
+
- COVERAGE_PATH="coverage/"
|
11
|
+
|
12
|
+
before_script:
|
13
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
14
|
+
- chmod +x ./cc-test-reporter
|
15
|
+
- ./cc-test-reporter before-build
|
16
|
+
|
17
|
+
after_script:
|
18
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
data/README.md
CHANGED
@@ -3,11 +3,10 @@ Meroku
|
|
3
3
|
|
4
4
|
because hosting 100 apps costs $700 ($7x100) at you-know-where.com
|
5
5
|
|
6
|
-
[![
|
6
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/cfec7757799809e85194/maintainability)](https://codeclimate.com/github/meroku/meroku/maintainability)
|
7
7
|
[![Coverage](https://img.shields.io/codeclimate/coverage/github/meroku/meroku.svg?style=flat-square)](https://codeclimate.com/github/meroku/meroku)
|
8
8
|
[![Build](https://img.shields.io/travis-ci/meroku/meroku.svg?style=flat-square)](https://travis-ci.org/meroku/meroku)
|
9
9
|
[![Dependencies](https://img.shields.io/gemnasium/meroku/meroku.svg?style=flat-square)](https://gemnasium.com/meroku/meroku)
|
10
|
-
[![Downloads](https://img.shields.io/gem/meroku/meroku.svg?style=flat-square)](https://rubygems.org/gems/meroku)
|
11
10
|
[![Issues](https://img.shields.io/github/issues/meroku/meroku.svg?style=flat-square)](https://github.com/meroku/meroku/issues)
|
12
11
|
[![License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](http://opensource.org/licenses/MIT)
|
13
12
|
[![Gem Version](https://badge.fury.io/rb/meroku.svg)](https://badge.fury.io/rb/meroku)
|
data/lib/meroku/aws.rb
CHANGED
@@ -5,28 +5,34 @@ module Meroku
|
|
5
5
|
module Aws
|
6
6
|
include Meroku::Shared
|
7
7
|
|
8
|
-
def
|
9
|
-
|
8
|
+
def default_instance_params
|
9
|
+
{
|
10
10
|
image_id: 'ami-841f46ff',
|
11
11
|
min_count: 1,
|
12
12
|
max_count: 1,
|
13
13
|
key_name: 'meroku.id_rsa',
|
14
14
|
instance_type: 't2.micro',
|
15
15
|
tag_specifications: [tag]
|
16
|
-
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def make_instance
|
20
|
+
@instance_id =
|
21
|
+
Meroku::Shared \
|
22
|
+
.ec2_client \
|
23
|
+
.run_instances(default_instance_params) \
|
24
|
+
.instances.fetch(0).instance_id
|
25
|
+
puts 'waiting'
|
26
|
+
Meroku::Shared.ec2_client.wait_until(
|
27
|
+
:instance_running,
|
28
|
+
instance_ids: [@instance_id]
|
29
|
+
)
|
17
30
|
end
|
18
31
|
|
19
32
|
def associate_address
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
puts Meroku::Shared.ec2_client.associate_address(
|
24
|
-
allocation_id: allocation_id, instance_id: instance_id
|
25
|
-
).class
|
26
|
-
sleep 20
|
27
|
-
rescue ::Aws::EC2::Errors::InvalidInstanceID
|
28
|
-
(retries += 1) < 10 ? retry : raise
|
29
|
-
end
|
33
|
+
Meroku::Shared.ec2_client.associate_address(
|
34
|
+
allocation_id: allocation_id, instance_id: instance_id
|
35
|
+
)
|
30
36
|
end
|
31
37
|
|
32
38
|
# Private S3 Bucket
|
data/lib/meroku/cli.rb
CHANGED
@@ -14,9 +14,14 @@ module Meroku
|
|
14
14
|
|
15
15
|
def run(args = ARGV)
|
16
16
|
@options = Options.new.parse(args)
|
17
|
+
act_on_user_options
|
17
18
|
act_on_options
|
18
|
-
rescue Meroku::
|
19
|
-
|
19
|
+
rescue Meroku::Success
|
20
|
+
return 0
|
21
|
+
rescue StandardError => e
|
22
|
+
print 'Error:'
|
23
|
+
print " #{e.message}" if e.message
|
24
|
+
print " <#{e.class}>\n"
|
20
25
|
return 2
|
21
26
|
end
|
22
27
|
|
@@ -27,10 +32,15 @@ module Meroku
|
|
27
32
|
Meroku::Shared.secrets.meroku_secret = @options[:meroku_secret]
|
28
33
|
end
|
29
34
|
Node.new if @options[:spawn]
|
30
|
-
User.login(@options[:email], @options[:password]) if @options[:login]
|
31
|
-
User.logout if @options[:logout]
|
32
35
|
Meroku::Aws.terminate_all(tag: 'node') if @options[:despawn]
|
33
36
|
true
|
34
37
|
end
|
38
|
+
|
39
|
+
def act_on_user_options
|
40
|
+
User.login(@options[:email], @options[:password]) if @options[:login]
|
41
|
+
User.logout if @options[:logout]
|
42
|
+
User.signup(@options[:email], @options[:password]) if @options[:signup]
|
43
|
+
User.unregister(@options) if @options[:unregister]
|
44
|
+
end
|
35
45
|
end
|
36
46
|
end
|
data/lib/meroku/error.rb
CHANGED
data/lib/meroku/node.rb
CHANGED
@@ -105,7 +105,7 @@ module Meroku
|
|
105
105
|
execute_script <<~HEREDOC
|
106
106
|
cd ~/backend_api; sudo gem install bundler; bundle;
|
107
107
|
cd ~/backend_api; SECRET=#{Meroku::Shared.secrets.meroku_secret} RAILS_ENV=production bundle exec rake db:migrate db:seed
|
108
|
-
cd ~/backend_api; SECRET=#{Meroku::Shared.secrets.meroku_secret} SECRET_KEY_BASE=#{Meroku::Shared.secrets.meroku_secret} RAILS_ENV=production bundle exec
|
108
|
+
cd ~/backend_api; SECRET=#{Meroku::Shared.secrets.meroku_secret} SECRET_KEY_BASE=#{Meroku::Shared.secrets.meroku_secret} RAILS_ENV=production bundle exec unicorn -D -l unix:///home/ubuntu/backend_api/tmp/backend_api.sock -c config/unicorn.rb
|
109
109
|
sudo /usr/sbin/nginx -s reload
|
110
110
|
HEREDOC
|
111
111
|
end
|
data/lib/meroku/options.rb
CHANGED
@@ -22,13 +22,27 @@ module Meroku
|
|
22
22
|
puts opts
|
23
23
|
end
|
24
24
|
|
25
|
-
|
25
|
+
add_users_registration_options(opts)
|
26
|
+
add_users_login_options(opts)
|
26
27
|
opts.separator ''
|
27
28
|
add_maintainers_options(opts)
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
31
|
-
def
|
32
|
+
def add_users_registration_options(opts)
|
33
|
+
option(opts, '--signup EMAIL,PASSWORD', Array) do |list|
|
34
|
+
@options[:signup] = true
|
35
|
+
@options[:email] = list[0]
|
36
|
+
@options[:password] = list[1]
|
37
|
+
end
|
38
|
+
option(opts, '--unregister EMAIL,PASSWORD', Array) do |list|
|
39
|
+
@options[:unregister] = true
|
40
|
+
@options[:email] = list[0]
|
41
|
+
@options[:password] = list[1]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def add_users_login_options(opts)
|
32
46
|
option(opts, '--login EMAIL,PASSWORD', Array) do |list|
|
33
47
|
@options[:login] = true
|
34
48
|
@options[:email] = list[0]
|
data/lib/meroku/user.rb
CHANGED
@@ -4,22 +4,63 @@ module Meroku
|
|
4
4
|
# Logic related to Users login, logout etc
|
5
5
|
module User
|
6
6
|
def self.login(email, password)
|
7
|
-
url = 'https://www.meroku.com/login.json'
|
8
7
|
data = { 'email' => email, 'password' => password }.to_json
|
9
|
-
result = RestClient.post
|
8
|
+
result = RestClient.post 'https://www.meroku.com/login.json',
|
10
9
|
data,
|
11
10
|
content_type: :json
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
process_error(result)
|
12
|
+
process_success(result) { |x| save_token(x) }
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.process_error(result)
|
16
|
+
raise Meroku::Error, JSON.parse(result).dig('errors') \
|
17
|
+
if JSON.parse(result).dig('errors')
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.process_success(result)
|
21
|
+
id = JSON.parse(result).dig('data', 'id')
|
22
|
+
if id
|
23
|
+
yield(result) if block_given?
|
24
|
+
puts "OK [#{id}]"
|
25
|
+
end
|
26
|
+
raise Meroku::Success
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.save_token(x)
|
30
|
+
token = JSON.parse(x).dig('data', 'id')
|
31
|
+
IO.write("#{Dir.home}/.meroku_token", token) if token
|
17
32
|
end
|
18
33
|
|
19
34
|
def self.logout
|
20
35
|
file = "#{Dir.home}/.meroku_token"
|
21
|
-
File.delete(file)
|
36
|
+
File.delete(file)
|
22
37
|
puts 'Logged out'
|
38
|
+
raise Meroku::Success
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.signup(email, password)
|
42
|
+
data = { 'email' => email, 'password' => password }.to_json
|
43
|
+
result = RestClient.post 'https://www.meroku.com/registrations.json',
|
44
|
+
data,
|
45
|
+
content_type: :json
|
46
|
+
process_error(result)
|
47
|
+
process_success(result) { |x| save_token(x) }
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.unregister(options)
|
51
|
+
data = { 'email' => options[:email], 'password' => options[:password] }
|
52
|
+
result = RestClient::Request.execute(
|
53
|
+
method: :delete,
|
54
|
+
url: 'https://www.meroku.com/registrations.json',
|
55
|
+
headers: { params: data }
|
56
|
+
)
|
57
|
+
process_error(result)
|
58
|
+
process_success(result) { delete_token }
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.delete_token
|
62
|
+
file = "#{Dir.home}/.meroku_token"
|
63
|
+
File.delete(file) if File.exist?(file)
|
23
64
|
end
|
24
65
|
end
|
25
66
|
end
|
data/lib/meroku/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: meroku
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Meroku System
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|