karo 1.5.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of karo might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/karo/assets.rb +9 -1
- data/lib/karo/cache.rb +10 -4
- data/lib/karo/cli.rb +84 -39
- data/lib/karo/db.rb +23 -4
- data/lib/karo/templates/karo.yml +9 -3
- data/lib/karo/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97b8833811a06035214ec406b17eca422d1bb1fb
|
4
|
+
data.tar.gz: e6114de86c07bd6bab12db6b2f4339e97c6b09f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed6f7dec23bf58f66b877ce3ea84e97a3c86d474a6a1a8854ea785da61247175c8874f6f36c96284ceb6a3d76e5c8a6d07265f346ad1dd6e906ceb93a65b1eb2
|
7
|
+
data.tar.gz: 7e0210d93ebc777cb9d21a9d6d14e7612fae4022fad53b778f27fb683c23556171be88d9780742df67ea49f7b1e5eff52dfb37626e6bb9cb5588598d61b8a259
|
data/CHANGELOG.md
CHANGED
data/lib/karo/assets.rb
CHANGED
@@ -10,6 +10,7 @@ module Karo
|
|
10
10
|
class_option :config_file, type: :string, default: Config.default_file_name,
|
11
11
|
aliases: "-c", desc: "name of the file containing server configuration"
|
12
12
|
class_option :environment, aliases: "-e", desc: "server environment", default: "production"
|
13
|
+
class_option :verbose, type: :boolean, lazy_default: true, aliases: "-v", desc: "verbose"
|
13
14
|
|
14
15
|
desc "pull", "syncs assets from server shared/system/dragonfly/<environment> directory into local system/dragonfly/development directory"
|
15
16
|
def pull
|
@@ -23,7 +24,9 @@ module Karo
|
|
23
24
|
host = "deploy@#{configuration["host"]}"
|
24
25
|
cmd = "rsync -az --progress #{host}:#{path_server}/ #{path_local}/"
|
25
26
|
|
26
|
-
|
27
|
+
say cmd, :green if options[:verbose]
|
28
|
+
|
29
|
+
system cmd
|
27
30
|
|
28
31
|
say "Assets sync complete", :green
|
29
32
|
end
|
@@ -44,6 +47,11 @@ module Karo
|
|
44
47
|
cmd_1 = "ssh #{host} 'mkdir -p #{path_server}'"
|
45
48
|
cmd_2 = "rsync -az --progress #{path_local}/ #{host}:#{path_server}/"
|
46
49
|
|
50
|
+
if options[:verbose]
|
51
|
+
say cmd_1, :green
|
52
|
+
say cmd_2, :green
|
53
|
+
end
|
54
|
+
|
47
55
|
if yes?("Are you sure?", :yellow)
|
48
56
|
system "#{cmd_1}"
|
49
57
|
system "#{cmd_2}"
|
data/lib/karo/cache.rb
CHANGED
@@ -13,10 +13,13 @@ module Karo
|
|
13
13
|
def search(name="")
|
14
14
|
configuration = Config.load_configuration(options)
|
15
15
|
path = File.join(configuration["path"], "shared/cache")
|
16
|
-
|
17
|
-
|
16
|
+
ssh = "ssh #{configuration["user"]}@#{configuration["host"]}"
|
17
|
+
cmd = "find #{path} -type f -name \"*#{name}*\""
|
18
|
+
|
19
|
+
to_run = "#{ssh} '#{cmd}'"
|
18
20
|
|
19
|
-
|
21
|
+
say to_run, :green if options[:verbose]
|
22
|
+
system to_run
|
20
23
|
end
|
21
24
|
|
22
25
|
desc "remove", "removes any matching cache files from the shared/cache directory"
|
@@ -28,8 +31,11 @@ module Karo
|
|
28
31
|
ssh = "ssh #{configuration["user"]}@#{configuration["host"]}"
|
29
32
|
cmd = "find #{path} -type f -name \"*#{name}*\" -delete"
|
30
33
|
|
34
|
+
to_run = "#{ssh} '#{cmd}'"
|
35
|
+
|
31
36
|
if yes?("Are you sure?", :yellow)
|
32
|
-
|
37
|
+
say to_run, :green if options[:verbose]
|
38
|
+
system to_run
|
33
39
|
say "Cache removed", :green
|
34
40
|
else
|
35
41
|
say "Cache not removed", :yellow
|
data/lib/karo/cli.rb
CHANGED
@@ -15,22 +15,7 @@ module Karo
|
|
15
15
|
class_option :config_file, type: :string, default: Config.default_file_name,
|
16
16
|
aliases: "-c", desc: "name of the file containing server configuration"
|
17
17
|
class_option :environment, aliases: "-e", desc: "server environment", default: "production"
|
18
|
-
|
19
|
-
desc "log", "displays server log for a given environment"
|
20
|
-
def log(name="")
|
21
|
-
configuration = Config.load_configuration(options)
|
22
|
-
|
23
|
-
path = File.join(configuration["path"], "shared/log/#{options["environment"]}.log")
|
24
|
-
ssh = "ssh #{configuration["user"]}@#{configuration["host"]}"
|
25
|
-
|
26
|
-
if name.eql?("")
|
27
|
-
cmd = "tail -f #{path}"
|
28
|
-
else
|
29
|
-
cmd = "tail #{path} | grep -A 10 -B 10 #{name}"
|
30
|
-
end
|
31
|
-
|
32
|
-
system "#{ssh} '#{cmd}'"
|
33
|
-
end
|
18
|
+
class_option :verbose, type: :boolean, lazy_default: true, aliases: "-v", desc: "verbose"
|
34
19
|
|
35
20
|
desc "cache [search, remove]", "find or clears a specific or all cache from shared/cache directory on the server"
|
36
21
|
subcommand "cache", Cache
|
@@ -58,11 +43,59 @@ module Karo
|
|
58
43
|
copy_file 'templates/karo.yml', config_file
|
59
44
|
end
|
60
45
|
|
61
|
-
desc "
|
46
|
+
desc "client [COMMAND]", "run any command within a given client environment"
|
47
|
+
long_desc <<-LONGDESC
|
48
|
+
`karo client [command]` or `karo clt [command]` will run the [COMMAND] cliently.
|
49
|
+
|
50
|
+
e.g. Display list of files on the client machine
|
51
|
+
|
52
|
+
> $ karo client ls
|
53
|
+
|
54
|
+
CHANGELOG.md Gemfile.lock README.md
|
55
|
+
|
56
|
+
You can also store custom commands for a given environment in the configuration file
|
57
|
+
|
58
|
+
e.g. .karo.yml
|
59
|
+
|
60
|
+
production:
|
61
|
+
|
62
|
+
--host: example.com
|
63
|
+
|
64
|
+
--user: deploy
|
65
|
+
|
66
|
+
--path: /data/app_name
|
67
|
+
|
68
|
+
--commands:
|
69
|
+
|
70
|
+
----client:
|
71
|
+
|
72
|
+
------deploy: ey deploy -e production -r master
|
73
|
+
|
74
|
+
> $ karo clt deploy
|
75
|
+
|
76
|
+
> Loading application data from Engine Yard Cloud...
|
77
|
+
|
78
|
+
> Beginning deploy...
|
79
|
+
LONGDESC
|
80
|
+
def client(cmd)
|
81
|
+
configuration = Config.load_configuration(options)
|
82
|
+
|
83
|
+
if configuration["commands"] && configuration["commands"]["client"] && configuration["commands"]["client"][cmd]
|
84
|
+
cmd = configuration["commands"]["client"][cmd]
|
85
|
+
end
|
86
|
+
|
87
|
+
say cmd, :green if options[:verbose]
|
88
|
+
|
89
|
+
system cmd
|
90
|
+
end
|
91
|
+
map clt: :client
|
92
|
+
map local: :client
|
93
|
+
|
94
|
+
desc "server [COMMAND]", "run any command within a given server environment"
|
62
95
|
method_option :tty, aliases: "-t", desc: "force pseudo-tty allocation",
|
63
96
|
type: :boolean, default: true
|
64
97
|
long_desc <<-LONGDESC
|
65
|
-
`karo
|
98
|
+
`karo server [command]` or `karo srv [command]`
|
66
99
|
|
67
100
|
will run the [COMMAND] passed on the server.
|
68
101
|
|
@@ -70,13 +103,13 @@ module Karo
|
|
70
103
|
|
71
104
|
e.g. Display list of files on the staging server
|
72
105
|
|
73
|
-
> $ karo
|
106
|
+
> $ karo server ls -e staging --no-tty
|
74
107
|
|
75
108
|
CHANGELOG.md Gemfile.lock README.md
|
76
109
|
|
77
110
|
e.g. Run top command on the production server
|
78
111
|
|
79
|
-
> $ karo
|
112
|
+
> $ karo server top
|
80
113
|
|
81
114
|
> top - 17:14:06 up 219 days, 11:30, 1 user, load average: 0.28, 0.49, 0.47
|
82
115
|
|
@@ -94,11 +127,13 @@ module Karo
|
|
94
127
|
|
95
128
|
--commands:
|
96
129
|
|
97
|
-
----
|
130
|
+
----server:
|
98
131
|
|
99
|
-
|
132
|
+
------memory: watch vmstat -sSM
|
100
133
|
|
101
|
-
|
134
|
+
------top_5_memory: ps aux | sort -nk +4 | tail
|
135
|
+
|
136
|
+
> $ karo srv memory
|
102
137
|
|
103
138
|
> Every 2.0s: vmstat -sSM Tue Jul 2 17:18:16 2013
|
104
139
|
|
@@ -108,7 +143,7 @@ module Karo
|
|
108
143
|
|
109
144
|
> 25224800 active memory
|
110
145
|
LONGDESC
|
111
|
-
def
|
146
|
+
def server(cmd)
|
112
147
|
configuration = Config.load_configuration(options)
|
113
148
|
|
114
149
|
ssh = "ssh #{configuration["user"]}@#{configuration["host"]}"
|
@@ -116,26 +151,21 @@ module Karo
|
|
116
151
|
# Forces pseudo-tty allocation
|
117
152
|
ssh << " -t" if options[:tty]
|
118
153
|
|
119
|
-
if configuration["commands"] && configuration["commands"][cmd]
|
120
|
-
cmd = configuration["commands"][cmd]
|
154
|
+
if configuration["commands"] && configuration["commands"]["server"] && configuration["commands"]["server"][cmd]
|
155
|
+
cmd = configuration["commands"]["server"][cmd]
|
121
156
|
end
|
122
157
|
|
123
|
-
|
124
|
-
end
|
125
|
-
map cmd: :command
|
158
|
+
to_run = "#{ssh} '#{cmd}'"
|
126
159
|
|
127
|
-
|
128
|
-
|
129
|
-
type: :boolean, default: true
|
130
|
-
def on(cmd)
|
131
|
-
say "Deprecated and will be removed in version 2.0", :yellow
|
132
|
-
say "Please use 'command' instead", :yellow
|
133
|
-
invoke :command
|
160
|
+
say to_run, :green if options[:verbose]
|
161
|
+
system to_run
|
134
162
|
end
|
163
|
+
map srv: :server
|
164
|
+
map remote: :server
|
135
165
|
|
136
166
|
desc "top", "run top command on a given server environment"
|
137
167
|
def top
|
138
|
-
invoke :
|
168
|
+
invoke :server, ["top"]
|
139
169
|
end
|
140
170
|
|
141
171
|
desc "ssh", "open ssh console for a given server environment"
|
@@ -146,7 +176,7 @@ module Karo
|
|
146
176
|
cmd = "cd #{path}; export RAILS_ENV=#{options[:environment]}; \
|
147
177
|
export RACK_ENV=#{options[:environment]}; $SHELL"
|
148
178
|
|
149
|
-
invoke :
|
179
|
+
invoke :server, [cmd]
|
150
180
|
end
|
151
181
|
|
152
182
|
desc "console", "open rails console for a given server environment"
|
@@ -156,7 +186,22 @@ module Karo
|
|
156
186
|
path = File.join(configuration["path"], "current")
|
157
187
|
cmd = "cd #{path} && bundle exec rails console #{options[:environment]}"
|
158
188
|
|
159
|
-
invoke :
|
189
|
+
invoke :server, [cmd]
|
190
|
+
end
|
191
|
+
|
192
|
+
desc "log", "displays server log for a given environment"
|
193
|
+
def log(name="")
|
194
|
+
configuration = Config.load_configuration(options)
|
195
|
+
|
196
|
+
path = File.join(configuration["path"], "shared/log/#{options["environment"]}.log")
|
197
|
+
|
198
|
+
if name.eql?("")
|
199
|
+
cmd = "tail -f #{path}"
|
200
|
+
else
|
201
|
+
cmd = "tail #{path} | grep -A 10 -B 10 #{name}"
|
202
|
+
end
|
203
|
+
|
204
|
+
invoke :server, [cmd]
|
160
205
|
end
|
161
206
|
|
162
207
|
desc "version", "displays karo's current version"
|
data/lib/karo/db.rb
CHANGED
@@ -13,6 +13,7 @@ module Karo
|
|
13
13
|
class_option :config_file, type: :string, default: Config.default_file_name,
|
14
14
|
aliases: "-c", desc: "name of the file containing server configuration"
|
15
15
|
class_option :environment, aliases: "-e", desc: "server environment", default: "production"
|
16
|
+
class_option :verbose, type: :boolean, lazy_default: true, aliases: "-v", desc: "verbose"
|
16
17
|
|
17
18
|
method_option :migrate, aliases: "-m", desc: "run migrations after sync", default: true
|
18
19
|
desc "pull", "syncs MySQL database from server to localhost"
|
@@ -52,11 +53,19 @@ module Karo
|
|
52
53
|
say "Loading #{options[:environment]} server database configuration", :green
|
53
54
|
|
54
55
|
# Drop local database and re-create
|
55
|
-
|
56
|
+
to_run = "mysql -v -h #{local_db_config["host"]} -u#{local_db_config["username"]} -p#{local_db_config["password"]} -e 'DROP DATABASE IF EXISTS `#{local_db_config["database"]}`; CREATE DATABASE IF NOT EXISTS `#{local_db_config["database"]}`;'"
|
57
|
+
|
58
|
+
say to_run, :green if options[:verbose]
|
59
|
+
|
60
|
+
system to_run
|
56
61
|
|
57
62
|
ssh = "ssh #{configuration["user"]}@#{configuration["host"]}"
|
58
63
|
|
59
|
-
|
64
|
+
to_run = "#{ssh} \"mysqldump --opt -C -u#{server_db_config["username"]} -p#{server_db_config["password"]} #{server_db_config["database"]}\" | mysql -v -h #{local_db_config["host"]} -C -u#{local_db_config["username"]} -p#{local_db_config["password"]} #{local_db_config["database"]}"
|
65
|
+
|
66
|
+
say to_run, :green if options[:verbose]
|
67
|
+
|
68
|
+
system to_run
|
60
69
|
|
61
70
|
if options[:migrate]
|
62
71
|
say "Running rake db:migrations", :green
|
@@ -72,13 +81,23 @@ module Karo
|
|
72
81
|
end
|
73
82
|
|
74
83
|
desc "console", "open rails dbconsole for a given server environment"
|
84
|
+
method_option :tty, aliases: "-t", desc: "force pseudo-tty allocation",
|
85
|
+
type: :boolean, default: true
|
75
86
|
def console
|
76
87
|
configuration = Config.load_configuration(options)
|
77
88
|
|
78
89
|
path = File.join(configuration["path"], "current")
|
79
|
-
ssh = "ssh #{configuration["user"]}@#{configuration["host"]}
|
90
|
+
ssh = "ssh #{configuration["user"]}@#{configuration["host"]}"
|
91
|
+
|
92
|
+
# Forces pseudo-tty allocation
|
93
|
+
ssh << " -t" if options[:tty]
|
94
|
+
|
80
95
|
cmd = "cd #{path} && bundle exec rails dbconsole #{options[:environment]} -p"
|
81
|
-
|
96
|
+
|
97
|
+
to_run = "#{ssh} '#{cmd}'"
|
98
|
+
|
99
|
+
say to_run, :green if options[:verbose]
|
100
|
+
system to_run
|
82
101
|
end
|
83
102
|
|
84
103
|
end
|
data/lib/karo/templates/karo.yml
CHANGED
@@ -3,11 +3,17 @@ production:
|
|
3
3
|
user: deploy
|
4
4
|
path: /data/app_name
|
5
5
|
commands:
|
6
|
-
|
7
|
-
|
6
|
+
server:
|
7
|
+
memory: watch vmstat -sSM
|
8
|
+
top_5_memory: ps aux | sort -nk +4 | tail
|
9
|
+
client:
|
10
|
+
deploy: ey deploy -e production -r master
|
8
11
|
staging:
|
9
12
|
host: example.com
|
10
13
|
user: deploy
|
11
14
|
path: /data/app_name
|
12
15
|
commands:
|
13
|
-
|
16
|
+
server:
|
17
|
+
memory: vmstat -sSM
|
18
|
+
client:
|
19
|
+
deploy: ey deploy -e staging -r staging
|
data/lib/karo/version.rb
CHANGED