dogids-cli 0.0.19 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dogids_cli.gemspec +1 -1
- data/lib/dogids.rb +1 -0
- data/lib/dogids/base.rb +12 -8
- data/lib/dogids/cache.rb +20 -15
- data/lib/dogids/cache/development.rb +14 -14
- data/lib/dogids/cache/production.rb +14 -14
- data/lib/dogids/cache/staging.rb +11 -11
- data/lib/dogids/config.rb +42 -24
- data/lib/dogids/deploy/staging.rb +35 -23
- data/lib/dogids/deploy/web.rb +2 -1
- data/lib/dogids/deploy/worker.rb +1 -1
- data/lib/dogids/reload.rb +39 -0
- data/lib/dogids/ssh.rb +11 -7
- data/lib/dogids/ssh/development.rb +16 -5
- data/lib/dogids/ssh/production.rb +7 -22
- data/lib/dogids/ssh/staging.rb +8 -4
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 648c482712018162c9cf439800a4bfb1e9a867f1
|
4
|
+
data.tar.gz: 7a1af27153ecce16015f4768470c1409f84fb6e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cfdbe776f64deeb3f5dde4317e87856ee57ecbd50a92f808fae8daeca4132d446af03e1db71b53c8ee8c5ea254cf3ca3b4d7184a46c6836f103cf2c21402ace
|
7
|
+
data.tar.gz: 5089f64b096667de2d450c8c48a2820417f62d79a2d0dbee99e875252335bb7c7ea48e27cf3d544d1da2b9b9b28e1d892daeaba7b48a98d769afd5109eb90791
|
data/dogids_cli.gemspec
CHANGED
@@ -5,7 +5,7 @@ require "dogids/version"
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "dogids-cli"
|
8
|
-
spec.version = "0.0.
|
8
|
+
spec.version = "0.0.20"
|
9
9
|
spec.authors = ["Jaryd Krishnan"]
|
10
10
|
spec.email = ["jaryd@dogids.com"]
|
11
11
|
spec.summary = "Command line tool for dogIDs tasks"
|
data/lib/dogids.rb
CHANGED
data/lib/dogids/base.rb
CHANGED
@@ -41,26 +41,31 @@ module Dogids
|
|
41
41
|
|
42
42
|
private
|
43
43
|
|
44
|
-
|
44
|
+
# Get configuration for environment and location
|
45
|
+
# @param [string] environment
|
46
|
+
# @param [string] location (Optional)
|
47
|
+
def get_config_url(environment, location = nil)
|
45
48
|
config_file = set_config_location
|
46
|
-
if
|
47
|
-
return config_file[
|
49
|
+
if location
|
50
|
+
return config_file[environment][location] if config_file[environment].has_key?(location)
|
51
|
+
elsif config_file.has_key?(environment)
|
52
|
+
return config_file[environment]
|
48
53
|
else
|
49
54
|
say("URL/IP hasn't been set for #{location} \n")
|
50
55
|
say("Please set this first by running: \n")
|
51
|
-
say("dogids config #{location}","\e[32m")
|
56
|
+
say("dogids config:#{environment} #{location}","\e[32m")
|
52
57
|
return false
|
53
58
|
end
|
54
59
|
end
|
55
60
|
|
56
61
|
# Print a heading to the terminal for commands that are going to be run.
|
57
|
-
# @param
|
62
|
+
# @param [String] heading
|
58
63
|
def print_heading(heading)
|
59
64
|
puts "-----> #{heading}"
|
60
65
|
end
|
61
66
|
|
62
67
|
# Print a message to the terminal about a command that's going to run.
|
63
|
-
# @param
|
68
|
+
# @param [String] command
|
64
69
|
def print_command(command)
|
65
70
|
command.split("\n").each do |line|
|
66
71
|
print_wrapped(line, indent: 7)
|
@@ -68,14 +73,13 @@ module Dogids
|
|
68
73
|
end
|
69
74
|
|
70
75
|
# Run a command with Bash after first printing the command to the terminal.
|
71
|
-
# @param
|
76
|
+
# @param [String] command
|
72
77
|
def run_command(command)
|
73
78
|
print_command(command)
|
74
79
|
`#{command}`
|
75
80
|
end
|
76
81
|
|
77
82
|
# Access local configuration file
|
78
|
-
# @param file [String]
|
79
83
|
def set_config_location
|
80
84
|
config = UserConfig.new('.dogids')
|
81
85
|
config['conf.yaml']
|
data/lib/dogids/cache.rb
CHANGED
@@ -10,23 +10,28 @@ module Dogids
|
|
10
10
|
puts " "
|
11
11
|
puts "Cache Commands:"
|
12
12
|
puts " "
|
13
|
-
puts "
|
14
|
-
puts " dogids cache
|
15
|
-
puts " dogids cache:dev css # Clear CSS cache for the dogids.dev storefront"
|
16
|
-
puts " dogids cache:dev javascript # Clear Javascript cache for the dogids.dev storefront"
|
17
|
-
puts " dogids cache:dev qa # Clear Q&A cache for the dogids.dev storefront"
|
13
|
+
puts " Use the following format:"
|
14
|
+
puts " dogids cache:<environment> <machine> <action>"
|
18
15
|
puts " "
|
19
|
-
puts "
|
20
|
-
puts " dogids cache:staging category # Clear category cache for the staging.dogids.com storefront"
|
21
|
-
puts " dogids cache:staging css # Clear CSS cache for the staging.dogids.com storefront"
|
22
|
-
puts " dogids cache:staging javascript # Clear Javascript cache for the staging.dogids.com storefront"
|
23
|
-
puts " dogids cache:staging qa # Clear Q&A cache for the staging.dogids.com storefront"
|
16
|
+
puts " Here are some basic examples:"
|
24
17
|
puts " "
|
25
|
-
puts " dogids cache:
|
26
|
-
puts " dogids cache:
|
27
|
-
puts " dogids cache:
|
28
|
-
puts " dogids cache:
|
29
|
-
puts " dogids cache:
|
18
|
+
puts " dogids cache:dev dev clear # Clear whole cache for the dogids.dev storefront"
|
19
|
+
puts " dogids cache:dev dev category # Clear category cache for the dogids.dev storefront"
|
20
|
+
puts " dogids cache:dev dev css # Clear CSS cache for the dogids.dev storefront"
|
21
|
+
puts " dogids cache:dev dev javascript # Clear Javascript cache for the dogids.dev storefront"
|
22
|
+
puts " dogids cache:dev dev qa # Clear Q&A cache for the dogids.dev storefront"
|
23
|
+
puts " "
|
24
|
+
puts " dogids cache:staging staging clear # Clear whole cache for the staging.dogids.com storefront"
|
25
|
+
puts " dogids cache:staging staging category # Clear category cache for the staging.dogids.com storefront"
|
26
|
+
puts " dogids cache:staging staging css # Clear CSS cache for the staging.dogids.com storefront"
|
27
|
+
puts " dogids cache:staging staging javascript # Clear Javascript cache for the staging.dogids.com storefront"
|
28
|
+
puts " dogids cache:staging staging qa # Clear Q&A cache for the staging.dogids.com storefront"
|
29
|
+
puts " "
|
30
|
+
puts " dogids cache:production web clear # Clear whole cache for the dogids.com storefront"
|
31
|
+
puts " dogids cache:production web category # Clear category cache for the dogids.dev storefront"
|
32
|
+
puts " dogids cache:production web css # Clear CSS cache for the production.dogids.com storefront"
|
33
|
+
puts " dogids cache:production web javascript # Clear Javascript cache for the production.dogids.com storefront"
|
34
|
+
puts " dogids cache:production web qa # Clear Q&A cache for the dogids.com storefront"
|
30
35
|
puts " "
|
31
36
|
end
|
32
37
|
end
|
@@ -4,36 +4,36 @@ require "thor"
|
|
4
4
|
module Dogids
|
5
5
|
class Cli < Thor
|
6
6
|
no_commands do
|
7
|
-
def cache_dev(vm_name = nil)
|
8
|
-
ssh_address = get_config_url("dev")
|
7
|
+
def cache_dev(vm_name = nil, cache = nil)
|
8
|
+
ssh_address = get_config_url("dev",vm_name)
|
9
9
|
return if ssh_address == false
|
10
10
|
|
11
|
-
case
|
11
|
+
case cache
|
12
12
|
when "category"
|
13
|
-
print_heading("Checking the category
|
13
|
+
print_heading("Checking the category items cache")
|
14
14
|
Net::SSH.start("#{ssh_address}", "dogids") do |ssh|
|
15
15
|
ssh.exec!(count_category_cache_files_dev_command) do |_channel, _stream, data|
|
16
16
|
print_command("Current category reviews: " + data)
|
17
17
|
end
|
18
|
-
if yes?("-----> Continue with clearing the cache? [no]")
|
19
|
-
print_heading("Clearing the development category cache")
|
18
|
+
if yes?("-----> Continue with clearing the DEV category items cache? [no]")
|
19
|
+
print_heading("Clearing the development category items cache")
|
20
20
|
ssh.exec!(clear_category_cache_dev_command) do |_channel, _stream, data|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
24
24
|
when "clear"
|
25
25
|
print_heading("Let's start clearing the entire dev cache")
|
26
|
-
cache_dev("category")
|
27
|
-
cache_dev("qa")
|
28
|
-
cache_dev("javascript")
|
29
|
-
cache_dev("css")
|
26
|
+
cache_dev(vm_name,"category")
|
27
|
+
cache_dev(vm_name,"qa")
|
28
|
+
cache_dev(vm_name,"javascript")
|
29
|
+
cache_dev(vm_name,"css")
|
30
30
|
when "css"
|
31
31
|
print_heading("Checking the CSS cache")
|
32
32
|
Net::SSH.start("#{ssh_address}", "dogids") do |ssh|
|
33
33
|
ssh.exec!(count_css_cache_files_dev_command) do |_channel, _stream, data|
|
34
34
|
print_command("Current CSS cache files: " + data)
|
35
35
|
end
|
36
|
-
if yes?("-----> Continue with clearing the CSS cache? [no]")
|
36
|
+
if yes?("-----> Continue with clearing the DEV CSS cache? [no]")
|
37
37
|
print_heading("Clearing the development CSS cache")
|
38
38
|
ssh.exec!(clear_css_cache_dev_command) do |_channel, _stream, data|
|
39
39
|
end
|
@@ -45,7 +45,7 @@ module Dogids
|
|
45
45
|
ssh.exec!(count_javascript_cache_files_dev_command) do |_channel, _stream, data|
|
46
46
|
print_command("Current Javascript cache files: " + data)
|
47
47
|
end
|
48
|
-
if yes?("-----> Continue with clearing the Javascript cache? [no]")
|
48
|
+
if yes?("-----> Continue with clearing the DEV Javascript cache? [no]")
|
49
49
|
print_heading("Clearing the development Javascript cache")
|
50
50
|
ssh.exec!(clear_javascript_cache_dev_command) do |_channel, _stream, data|
|
51
51
|
end
|
@@ -57,8 +57,8 @@ module Dogids
|
|
57
57
|
ssh.exec!(count_qa_cache_files_dev_command) do |_channel, _stream, data|
|
58
58
|
print_command("Current category reviews: " + data)
|
59
59
|
end
|
60
|
-
if yes?("-----> Continue with clearing
|
61
|
-
print_heading("Clearing the development
|
60
|
+
if yes?("-----> Continue with clearing the DEV product Q&A cache? [no]")
|
61
|
+
print_heading("Clearing the development Q&A cache")
|
62
62
|
ssh.exec!(clear_qa_cache_dev_command) do |_channel, _stream, data|
|
63
63
|
end
|
64
64
|
end
|
@@ -4,36 +4,36 @@ require "thor"
|
|
4
4
|
module Dogids
|
5
5
|
class Cli < Thor
|
6
6
|
no_commands do
|
7
|
-
def cache_production(vm_name = nil)
|
8
|
-
ssh_address = get_config_url("
|
7
|
+
def cache_production(vm_name = nil, cache = nil)
|
8
|
+
ssh_address = get_config_url("production",vm_name)
|
9
9
|
return if ssh_address == false
|
10
10
|
|
11
|
-
case
|
11
|
+
case cache
|
12
12
|
when "category"
|
13
|
-
print_heading("Checking the category
|
13
|
+
print_heading("Checking the category items cache")
|
14
14
|
Net::SSH.start("#{ssh_address}", "dogids") do |ssh|
|
15
15
|
ssh.exec!(count_category_cache_files_production_command) do |_channel, _stream, data|
|
16
16
|
print_command("Current category reviews: " + data)
|
17
17
|
end
|
18
|
-
if yes?("-----> Continue with clearing the cache? [no]")
|
19
|
-
print_heading("Clearing the production category cache")
|
18
|
+
if yes?("-----> Continue with clearing the PRODUCTION category items cache? [no]")
|
19
|
+
print_heading("Clearing the production category items cache")
|
20
20
|
ssh.exec!(clear_category_cache_production_command) do |_channel, _stream, data|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
24
24
|
when "clear"
|
25
25
|
print_heading("Let's start clearing the entire production cache")
|
26
|
-
cache_production("category")
|
27
|
-
cache_production("qa")
|
28
|
-
|
29
|
-
|
26
|
+
cache_production(vm_name,"category")
|
27
|
+
cache_production(vm_name,"qa")
|
28
|
+
cache_production(vm_name,"javascript")
|
29
|
+
cache_production(vm_name,"css")
|
30
30
|
when "css"
|
31
31
|
print_heading("Checking the CSS cache")
|
32
32
|
Net::SSH.start("#{ssh_address}", "dogids") do |ssh|
|
33
33
|
ssh.exec!(count_css_cache_files_production_command) do |_channel, _stream, data|
|
34
34
|
print_command("Current CSS cache files: " + data)
|
35
35
|
end
|
36
|
-
if yes?("-----> Continue with clearing the CSS cache? [no]")
|
36
|
+
if yes?("-----> Continue with clearing the PRODUCTION CSS cache? [no]")
|
37
37
|
print_heading("Clearing the development CSS cache")
|
38
38
|
ssh.exec!(clear_css_cache_production_command) do |_channel, _stream, data|
|
39
39
|
end
|
@@ -45,7 +45,7 @@ module Dogids
|
|
45
45
|
ssh.exec!(count_javascript_cache_files_production_command) do |_channel, _stream, data|
|
46
46
|
print_command("Current Javascript cache files: " + data)
|
47
47
|
end
|
48
|
-
if yes?("-----> Continue with clearing the Javascript cache? [no]")
|
48
|
+
if yes?("-----> Continue with clearing the PRODUCTION Javascript cache? [no]")
|
49
49
|
print_heading("Clearing the development Javascript cache")
|
50
50
|
ssh.exec!(clear_javascript_cache_production_command) do |_channel, _stream, data|
|
51
51
|
end
|
@@ -57,8 +57,8 @@ module Dogids
|
|
57
57
|
ssh.exec!(count_qa_cache_files_production_command) do |_channel, _stream, data|
|
58
58
|
print_command("Current category reviews: " + data)
|
59
59
|
end
|
60
|
-
if yes?("-----> Continue with clearing
|
61
|
-
print_heading("Clearing the production
|
60
|
+
if yes?("-----> Continue with clearing the PRODUCTION product Q&A cache? [no]")
|
61
|
+
print_heading("Clearing the production product Q&A cache")
|
62
62
|
ssh.exec!(clear_qa_cache_production_command) do |_channel, _stream, data|
|
63
63
|
end
|
64
64
|
end
|
data/lib/dogids/cache/staging.rb
CHANGED
@@ -4,17 +4,17 @@ require "thor"
|
|
4
4
|
module Dogids
|
5
5
|
class Cli < Thor
|
6
6
|
no_commands do
|
7
|
-
def cache_staging(vm_name = nil)
|
8
|
-
ssh_address = get_config_url("staging")
|
7
|
+
def cache_staging(vm_name = nil, cache = nil)
|
8
|
+
ssh_address = get_config_url("staging",vm_name)
|
9
9
|
return if ssh_address == false
|
10
|
-
case
|
10
|
+
case cache
|
11
11
|
when "category"
|
12
12
|
print_heading("Checking the category reviews cache")
|
13
13
|
Net::SSH.start("#{ssh_address}", "dogids") do |ssh|
|
14
14
|
ssh.exec!(count_category_cache_files_staging_command) do |_channel, _stream, data|
|
15
15
|
print_command("Current category reviews: " + data)
|
16
16
|
end
|
17
|
-
if yes?("-----> Continue with clearing the cache? [no]")
|
17
|
+
if yes?("-----> Continue with clearing the STAGING category item cache? [no]")
|
18
18
|
print_heading("Clearing the staging category cache")
|
19
19
|
ssh.exec!(clear_category_cache_staging_command) do |_channel, _stream, data|
|
20
20
|
end
|
@@ -22,17 +22,17 @@ module Dogids
|
|
22
22
|
end
|
23
23
|
when "clear"
|
24
24
|
print_heading("Let's start clearing the entire staging cache")
|
25
|
-
cache_staging("category")
|
26
|
-
cache_staging("qa")
|
27
|
-
|
28
|
-
|
25
|
+
cache_staging(vm_name,"category")
|
26
|
+
cache_staging(vm_name,"qa")
|
27
|
+
cache_staging(vm_name,"javascript")
|
28
|
+
cache_staging(vm_name,"css")
|
29
29
|
when "css"
|
30
30
|
print_heading("Checking the CSS cache")
|
31
31
|
Net::SSH.start("#{ssh_address}", "dogids") do |ssh|
|
32
32
|
ssh.exec!(count_css_cache_files_staging_command) do |_channel, _stream, data|
|
33
33
|
print_command("Current CSS cache files: " + data)
|
34
34
|
end
|
35
|
-
if yes?("-----> Continue with clearing the CSS cache? [no]")
|
35
|
+
if yes?("-----> Continue with clearing the STAGING CSS cache? [no]")
|
36
36
|
print_heading("Clearing the development CSS cache")
|
37
37
|
ssh.exec!(clear_css_cache_staging_command) do |_channel, _stream, data|
|
38
38
|
end
|
@@ -44,7 +44,7 @@ module Dogids
|
|
44
44
|
ssh.exec!(count_javascript_cache_files_staging_command) do |_channel, _stream, data|
|
45
45
|
print_command("Current Javascript cache files: " + data)
|
46
46
|
end
|
47
|
-
if yes?("-----> Continue with clearing the Javascript cache? [no]")
|
47
|
+
if yes?("-----> Continue with clearing the STAGING Javascript cache? [no]")
|
48
48
|
print_heading("Clearing the development Javascript cache")
|
49
49
|
ssh.exec!(clear_javascript_cache_staging_command) do |_channel, _stream, data|
|
50
50
|
end
|
@@ -56,7 +56,7 @@ module Dogids
|
|
56
56
|
ssh.exec!(count_qa_cache_files_staging_command) do |_channel, _stream, data|
|
57
57
|
print_command("Current category reviews: " + data)
|
58
58
|
end
|
59
|
-
if yes?("-----> Continue with clearing
|
59
|
+
if yes?("-----> Continue with clearing the STAGING product Q&A cache? [no]")
|
60
60
|
print_heading("Clearing the staging QA cache")
|
61
61
|
ssh.exec!(clear_qa_cache_staging_command) do |_channel, _stream, data|
|
62
62
|
end
|
data/lib/dogids/config.rb
CHANGED
@@ -9,51 +9,68 @@ module Dogids
|
|
9
9
|
case command
|
10
10
|
when "list"
|
11
11
|
list
|
12
|
-
when "admin"
|
13
|
-
set_config("admin")
|
14
|
-
when "db"
|
15
|
-
set_config("db")
|
16
|
-
when "dev"
|
17
|
-
set_config("dev")
|
18
|
-
when "staging"
|
19
|
-
set_config("staging")
|
20
|
-
when "web"
|
21
|
-
set_config("web")
|
22
|
-
when "worker"
|
23
|
-
set_config("worker")
|
24
12
|
else
|
25
13
|
puts " "
|
26
14
|
puts "Config Commands:"
|
27
15
|
puts " "
|
16
|
+
puts " Use the following so set environments:"
|
17
|
+
puts " dogids config:<environment> <machine>"
|
18
|
+
puts " "
|
28
19
|
puts " dogids config list # List all current configurations"
|
29
20
|
puts " "
|
30
|
-
puts " dogids config
|
31
|
-
puts " dogids config
|
32
|
-
puts " dogids config
|
33
|
-
puts " dogids config staging # Set URL/IP for Staging"
|
34
|
-
puts " dogids config web # Set URL/IP for Web"
|
35
|
-
puts " dogids config worker # Set URL/IP for Worker"
|
21
|
+
puts " dogids config:dev # Set URL/IP for Development Machines"
|
22
|
+
puts " dogids config:production # Set URL/IP for Production Machines"
|
23
|
+
puts " dogids config:staging # Set URL/IP for Staging machines"
|
36
24
|
puts " "
|
37
25
|
end
|
38
26
|
end
|
39
27
|
|
40
28
|
no_commands do
|
29
|
+
|
30
|
+
# Config dev environment
|
31
|
+
# @param [string] location
|
32
|
+
def config_dev(location = nil)
|
33
|
+
location ? set_config("dev",location) : config
|
34
|
+
end
|
35
|
+
|
36
|
+
# Config staging environment
|
37
|
+
# @param [string] location
|
38
|
+
def config_staging(location = nil)
|
39
|
+
location ? set_config("staging",location) : config
|
40
|
+
end
|
41
|
+
|
42
|
+
# Config production environment
|
43
|
+
# @param [string] location
|
44
|
+
def config_production(location = nil)
|
45
|
+
location ? set_config("production",location) : config
|
46
|
+
end
|
47
|
+
|
41
48
|
def list
|
42
49
|
dogids_config = set_config_location
|
43
50
|
if dogids_config.any? then
|
44
|
-
say("The following configurations are set: \n
|
45
|
-
|
51
|
+
say("The following configurations are set: \n")
|
52
|
+
dogids_config.each do |environment, locations|
|
53
|
+
say("\n##### #{environment}")
|
54
|
+
print_table(locations)
|
55
|
+
end
|
46
56
|
else
|
47
57
|
say("No configuration values have been set. Here's the command list:")
|
48
58
|
config
|
49
59
|
end
|
50
60
|
end
|
51
61
|
|
52
|
-
|
62
|
+
# Set configuration files based on environment and location
|
63
|
+
# @param [string] environment
|
64
|
+
# @param [string] location
|
65
|
+
def set_config(environment,location)
|
53
66
|
dogids_config = set_config_location
|
67
|
+
environment_configuration = Hash.new
|
68
|
+
if dogids_config["#{environment}"]
|
69
|
+
environment_configuration = dogids_config["#{environment}"].to_hash
|
70
|
+
end
|
54
71
|
current_value = ""
|
55
|
-
if dogids_config
|
56
|
-
current_value =
|
72
|
+
if dogids_config["#{environment}"] != nil && dogids_config["#{environment}"]["#{location}"] != nil then
|
73
|
+
current_value = get_config_url(environment, location)
|
57
74
|
say("Current #{location} URL/IP: #{current_value} \n","\e[32m")
|
58
75
|
set_new = yes?("-------> Do you want to enter a new value?[no]")
|
59
76
|
return if set_new != true
|
@@ -71,7 +88,8 @@ module Dogids
|
|
71
88
|
confirm = yes?("-------> Do you want to #{confirm_string}?[no]")
|
72
89
|
return if confirm != true
|
73
90
|
end
|
74
|
-
|
91
|
+
environment_configuration[location] = new_value
|
92
|
+
dogids_config["#{environment}"] = environment_configuration
|
75
93
|
dogids_config.save
|
76
94
|
say("The new URL/IP for #{location}: #{new_value}","\e[32m")
|
77
95
|
end
|
@@ -6,41 +6,53 @@ module Dogids
|
|
6
6
|
no_commands do
|
7
7
|
def deploy_staging
|
8
8
|
print_heading("Deploying dogids.com site to staging server")
|
9
|
-
ssh_address = get_config_url("staging")
|
10
9
|
|
11
|
-
Net::SSH.start("#{ssh_address}", "dogids") do |ssh|
|
12
|
-
print_command("Checking the current git status")
|
13
|
-
ssh.exec!(staging_git_status_command) do |_channel, _stream, data|
|
14
|
-
print_command(data)
|
15
|
-
end
|
16
10
|
|
17
|
-
|
11
|
+
server_addresses = [
|
12
|
+
"staging",
|
13
|
+
"staging2"
|
14
|
+
]
|
15
|
+
|
16
|
+
server_addresses.each do |server_address|
|
17
|
+
|
18
|
+
ssh_address = get_config_url("staging",server_address)
|
19
|
+
next if ssh_address == false
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
data.split("\n").each do |branch|
|
24
|
-
print_command(branch.gsub("origin/", ""))
|
21
|
+
Net::SSH.start("#{ssh_address}", "dogids") do |ssh|
|
22
|
+
print_command("Checking the current git status")
|
23
|
+
ssh.exec!(staging_git_status_command) do |_channel, _stream, data|
|
24
|
+
print_command(data)
|
25
25
|
end
|
26
|
-
end
|
27
26
|
|
28
|
-
|
29
|
-
return print_command("Fine, be that way.") if branch.length == 0
|
27
|
+
current_branch = ssh.exec!("cd /home/dogids/apps/dogids.com && git rev-parse --abbrev-ref HEAD").strip
|
30
28
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
print_heading("Current Branch: #{current_branch}")
|
30
|
+
print_heading("Available Branches:")
|
31
|
+
ssh.exec!("cd /home/dogids/apps/dogids.com && git branch -r --no-merged master") do |_channel, _stream, data|
|
32
|
+
print_command("master")
|
33
|
+
data.split("\n").each do |branch|
|
34
|
+
print_command(branch.gsub("origin/", ""))
|
35
|
+
end
|
36
|
+
end
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
-
|
38
|
+
branch = ask("-----> Which branch would you like to deploy?").strip
|
39
|
+
break print_command("Fine, be that way.") if branch.length == 0
|
40
|
+
|
41
|
+
print_command("Pulling latest from #{branch}")
|
42
|
+
ssh.exec!(staging_git_pull_command(branch)) do |_channel, _stream, data|
|
43
|
+
print_command(data)
|
44
|
+
end
|
45
|
+
|
46
|
+
print_command("Updating file permissions")
|
47
|
+
ssh.exec!(web_update_permissions_command) do |_channel, _stream, data|
|
48
|
+
print_command(data)
|
49
|
+
end
|
39
50
|
end
|
40
51
|
end
|
41
52
|
|
42
53
|
print_heading("Done.")
|
43
54
|
end
|
55
|
+
|
44
56
|
end
|
45
57
|
|
46
58
|
private
|
data/lib/dogids/deploy/web.rb
CHANGED
@@ -9,11 +9,12 @@ module Dogids
|
|
9
9
|
|
10
10
|
server_addresses = [
|
11
11
|
"web",
|
12
|
+
"web2",
|
12
13
|
"admin"
|
13
14
|
]
|
14
15
|
|
15
16
|
server_addresses.each do |server_address|
|
16
|
-
ssh_address = get_config_url("#{server_address}")
|
17
|
+
ssh_address = get_config_url("production","#{server_address}")
|
17
18
|
next if ssh_address == false
|
18
19
|
|
19
20
|
print_command("Server(#{server_address}): #{ssh_address}")
|
data/lib/dogids/deploy/worker.rb
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
require "thor"
|
2
|
+
module Dogids
|
3
|
+
class Cli < Thor
|
4
|
+
desc "reload", "Reloads the specified machine. Defaults to development"
|
5
|
+
|
6
|
+
# Reload the specified environment
|
7
|
+
# TODO add environments
|
8
|
+
# @param [string] app_name
|
9
|
+
def reload(app_name = nil)
|
10
|
+
if yes?("-----> Reload development? [no]")
|
11
|
+
reload_development_machine
|
12
|
+
else
|
13
|
+
update_vagrant_box if yes?("-----> Update Vagrant Box? (NOT RECOMMENDED) [no]")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
no_commands do
|
18
|
+
|
19
|
+
# Upgrade local vagrant box (default is ubuntu/trusty64)
|
20
|
+
def update_vagrant_box
|
21
|
+
say("-----> Updating the vagrant box...","\e[32m")
|
22
|
+
system("cd ~/dogids-vagrant && vagrant box update")
|
23
|
+
system("cd ~/dogids-vagrant && vagrant box list")
|
24
|
+
if yes?("-----> Remove old boxes? (NOT RECOMMENDED) [no]")
|
25
|
+
system("cd ~/dogids-vagrant && vagrant box remove --all")
|
26
|
+
system("cd ~/dogids-vagrant && vagrant box add ubuntu/trusty64")
|
27
|
+
end
|
28
|
+
reload_development_machine
|
29
|
+
end
|
30
|
+
|
31
|
+
# Reloads development machine
|
32
|
+
def reload_development_machine
|
33
|
+
say("-----> Reloading the development machine...","\e[32m")
|
34
|
+
system("cd ~/dogids-vagrant && vagrant reload")
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/dogids/ssh.rb
CHANGED
@@ -9,21 +9,25 @@ module Dogids
|
|
9
9
|
def ssh(vm_name = nil)
|
10
10
|
case vm_name
|
11
11
|
when "dev"
|
12
|
-
|
12
|
+
ssh_dev(vm_name)
|
13
13
|
when "staging"
|
14
14
|
ssh_staging(vm_name)
|
15
15
|
else
|
16
16
|
puts "Development SSH Commands:"
|
17
|
-
puts " dogids ssh dev
|
17
|
+
puts " dogids ssh:dev dev # SSH into local development VM"
|
18
|
+
puts " dogids ssh:dev lb # SSH into local development LB"
|
18
19
|
puts " "
|
19
20
|
puts "Staging SSH Commands:"
|
20
|
-
puts " dogids ssh
|
21
|
+
puts " dogids ssh:staging lb # SSH into staging LB"
|
22
|
+
puts " dogids ssh:staging staging # SSH into staging Apache/PHP/MySQL VM"
|
21
23
|
puts " "
|
22
24
|
puts "Production SSH Commands:"
|
23
|
-
puts " dogids ssh:production
|
24
|
-
puts " dogids ssh:production
|
25
|
-
puts " dogids ssh:production
|
26
|
-
puts " dogids ssh:production
|
25
|
+
puts " dogids ssh:production lb # SSH into production LB"
|
26
|
+
puts " dogids ssh:production railgun # SSH into production railgun instance"
|
27
|
+
puts " dogids ssh:production admin # SSH into VM for long running admin processes"
|
28
|
+
puts " dogids ssh:production db # SSH into production MySQL/Redis VM"
|
29
|
+
puts " dogids ssh:production web # SSH into production Apache/PHP VM"
|
30
|
+
puts " dogids ssh:production worker # SSH into production Ruby/Sidekiq VM"
|
27
31
|
puts " "
|
28
32
|
end
|
29
33
|
end
|
@@ -3,11 +3,22 @@ require "thor"
|
|
3
3
|
module Dogids
|
4
4
|
class Cli < Thor
|
5
5
|
no_commands do
|
6
|
-
def
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
def ssh_dev(vm_name = nil)
|
7
|
+
dev_machines = get_config_url("dev")
|
8
|
+
if dev_machines.has_key?(vm_name)
|
9
|
+
ssh_address = get_config_url("dev",vm_name)
|
10
|
+
if vm_name == "lb"
|
11
|
+
if yes?("----> Have you set up the dogIDs user for the development LB? [no]")
|
12
|
+
puts "Running: dogids@#{ssh_address}"
|
13
|
+
exec("ssh dogids@#{ssh_address}")
|
14
|
+
else
|
15
|
+
puts "Running: `cd ~/dogids-vagrant && vagrant ssh loadbalancer`"
|
16
|
+
exec("cd ~/dogids-vagrant && vagrant ssh loadbalancer")
|
17
|
+
end
|
18
|
+
else
|
19
|
+
puts "Running: `ssh -R 52698:localhost:52698 dogids@#{ssh_address}`"
|
20
|
+
exec("ssh -R 52698:localhost:52698 dogids@#{ssh_address}")
|
21
|
+
end
|
11
22
|
else
|
12
23
|
ssh
|
13
24
|
end
|
@@ -4,28 +4,13 @@ module Dogids
|
|
4
4
|
class Cli < Thor
|
5
5
|
no_commands do
|
6
6
|
def ssh_production(vm_name = nil)
|
7
|
-
|
8
|
-
|
9
|
-
ssh_address = get_config_url(vm_name)
|
10
|
-
if
|
11
|
-
puts "Running: `ssh
|
12
|
-
exec("ssh
|
13
|
-
|
14
|
-
when "db"
|
15
|
-
ssh_address = get_config_url(vm_name)
|
16
|
-
if ssh_address then
|
17
|
-
puts "Running: `ssh -R 52698:localhost:52698 dogids@#{ssh_address}`"
|
18
|
-
exec("ssh -R 52698:localhost:52698 dogids@#{ssh_address}")
|
19
|
-
end
|
20
|
-
when "web"
|
21
|
-
ssh_address = get_config_url(vm_name)
|
22
|
-
if ssh_address then
|
23
|
-
puts "Running: `ssh -R 52698:localhost:52698 dogids@#{ssh_address}`"
|
24
|
-
exec("ssh -R 52698:localhost:52698 dogids@#{ssh_address}")
|
25
|
-
end
|
26
|
-
when "worker"
|
27
|
-
ssh_address = get_config_url(vm_name)
|
28
|
-
if ssh_address then
|
7
|
+
production_machines = get_config_url("production")
|
8
|
+
if production_machines.has_key?(vm_name)
|
9
|
+
ssh_address = get_config_url("production",vm_name)
|
10
|
+
if vm_name == "lb" || vm_name == "railgun"
|
11
|
+
puts "Running: `ssh root@#{ssh_address}`"
|
12
|
+
exec("ssh root@#{ssh_address}")
|
13
|
+
else
|
29
14
|
puts "Running: `ssh -R 52698:localhost:52698 dogids@#{ssh_address}`"
|
30
15
|
exec("ssh -R 52698:localhost:52698 dogids@#{ssh_address}")
|
31
16
|
end
|
data/lib/dogids/ssh/staging.rb
CHANGED
@@ -4,10 +4,14 @@ module Dogids
|
|
4
4
|
class Cli < Thor
|
5
5
|
no_commands do
|
6
6
|
def ssh_staging(vm_name = nil)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
staging_machines = get_config_url("staging")
|
8
|
+
if staging_machines.has_key?(vm_name)
|
9
|
+
ssh_address = get_config_url("staging",vm_name)
|
10
|
+
if vm_name == "lb"
|
11
|
+
puts "Running: `ssh root@#{ssh_address}`"
|
12
|
+
exec("ssh root@#{ssh_address}")
|
13
|
+
else
|
14
|
+
puts "Running: `ssh -R 52698:localhost:52698 dogids@#{ssh_address}`"
|
11
15
|
exec("ssh -R 52698:localhost:52698 dogids@#{ssh_address}")
|
12
16
|
end
|
13
17
|
else
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dogids-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jaryd Krishnan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- lib/dogids/deploy/staging.rb
|
79
79
|
- lib/dogids/deploy/web.rb
|
80
80
|
- lib/dogids/deploy/worker.rb
|
81
|
+
- lib/dogids/reload.rb
|
81
82
|
- lib/dogids/ssh.rb
|
82
83
|
- lib/dogids/ssh/development.rb
|
83
84
|
- lib/dogids/ssh/production.rb
|