ors 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ors/commands/changes.rb +3 -4
- data/lib/ors/commands/check.rb +1 -4
- data/lib/ors/commands/console.rb +3 -5
- data/lib/ors/commands/exec.rb +1 -3
- data/lib/ors/commands/logs.rb +3 -4
- data/lib/ors/commands/runner.rb +3 -5
- data/lib/ors/commands/setup.rb +4 -5
- data/lib/ors/commands/update.rb +1 -2
- data/lib/ors/helpers.rb +19 -18
- data/lib/ors/version.rb +1 -1
- data/spec/ors/commands/console_spec.rb +1 -1
- data/spec/ors/commands/runner_spec.rb +2 -2
- data/spec/ors/commands/update_spec.rb +1 -1
- metadata +2 -2
data/lib/ors/commands/changes.rb
CHANGED
@@ -3,10 +3,9 @@ module ORS::Commands
|
|
3
3
|
class Changes < Base
|
4
4
|
|
5
5
|
def execute
|
6
|
-
results = execute_command console_server,
|
7
|
-
|
8
|
-
|
9
|
-
end
|
6
|
+
results = execute_command console_server, prepare_environment, %(git show | head -1), :capture => true
|
7
|
+
|
8
|
+
system('git', 'log', [$1, "remotes/origin/#{environment}"].join("..")) if results =~ /commit (.*)/
|
10
9
|
end
|
11
10
|
|
12
11
|
end
|
data/lib/ors/commands/check.rb
CHANGED
@@ -4,10 +4,7 @@ module ORS::Commands
|
|
4
4
|
timestamps = app_servers.map do |server|
|
5
5
|
[
|
6
6
|
"[#{server}] ",
|
7
|
-
execute_command(server,
|
8
|
-
%(cd #{deploy_directory}),
|
9
|
-
%(cat restart.timestamp),
|
10
|
-
:capture => true)
|
7
|
+
execute_command(server, prepare_environment, %(cat restart.timestamp), :capture => true)
|
11
8
|
].join
|
12
9
|
end.join("\n")
|
13
10
|
|
data/lib/ors/commands/console.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
module ORS::Commands
|
2
2
|
class Console < Base
|
3
3
|
def execute
|
4
|
-
execute_command console_server,
|
5
|
-
|
6
|
-
|
7
|
-
%(if [ -f script/rails ]; then bundle exec rails console #{environment}; else ./script/console #{environment}; fi),
|
8
|
-
:exec => true
|
4
|
+
execute_command console_server, prepare_environment,
|
5
|
+
%(if [ -f script/rails ]; then bundle exec rails console #{environment}; else ./script/console #{environment}; fi),
|
6
|
+
:exec => true
|
9
7
|
end
|
10
8
|
|
11
9
|
def help
|
data/lib/ors/commands/exec.rb
CHANGED
@@ -5,9 +5,7 @@ module ORS::Commands
|
|
5
5
|
def execute
|
6
6
|
info "executing command for #{name} #{environment}..."
|
7
7
|
|
8
|
-
execute_command migration_server, %(
|
9
|
-
%(cd #{deploy_directory}),
|
10
|
-
%(bundle exec #{ENV["CMD"]})
|
8
|
+
execute_command migration_server, prepare_environment, %(bundle exec #{ENV["CMD"]})
|
11
9
|
end
|
12
10
|
|
13
11
|
end
|
data/lib/ors/commands/logs.rb
CHANGED
@@ -5,10 +5,9 @@ module ORS::Commands
|
|
5
5
|
all_logs = app_servers.map do |server|
|
6
6
|
[
|
7
7
|
server,
|
8
|
-
execute_command(server,
|
9
|
-
|
10
|
-
|
11
|
-
:capture => true)
|
8
|
+
execute_command(server, prepare_environment,
|
9
|
+
%(tail -n #{log_lines} log/#{environment}.log),
|
10
|
+
:capture => true)
|
12
11
|
]
|
13
12
|
end
|
14
13
|
|
data/lib/ors/commands/runner.rb
CHANGED
@@ -7,11 +7,9 @@ module ORS::Commands
|
|
7
7
|
rescue
|
8
8
|
fatal "ERROR: Missing option --code 'ruby code'."
|
9
9
|
end
|
10
|
-
results = execute_command console_server,
|
11
|
-
|
12
|
-
|
13
|
-
%(if [ -f script/rails ]; then bundle exec rails runner -e #{environment} \\"#{code}\\"; else ./script/runner -e #{environment} \\"#{code}\\"; fi),
|
14
|
-
:capture => true, :quiet_ssh => true
|
10
|
+
results = execute_command console_server, prepare_environment,
|
11
|
+
%(if [ -f script/rails ]; then bundle exec rails runner -e #{environment} \\"#{code}\\"; else ./script/runner -e #{environment} \\"#{code}\\"; fi),
|
12
|
+
:capture => true, :quiet_ssh => true
|
15
13
|
results.sub!(/\AUsing BufferedLogger due to exception: .*?\n/, '') # The central_logger gem spits this out without any way of shutting it up
|
16
14
|
puts results
|
17
15
|
end
|
data/lib/ors/commands/setup.rb
CHANGED
@@ -5,16 +5,15 @@ module ORS::Commands
|
|
5
5
|
def execute
|
6
6
|
info "setting up #{name} #{environment}..."
|
7
7
|
|
8
|
-
info "Are you sure? ('
|
9
|
-
if STDIN.read == "
|
8
|
+
info "Are you sure? ('yes' + ctrl+D^2)"
|
9
|
+
if STDIN.read == "yes"
|
10
10
|
execute_in_parallel(all_servers) {|server| setup_repo server }
|
11
11
|
execute_in_parallel(ruby_servers) {|server| setup_ruby server }
|
12
12
|
|
13
|
-
execute_command migration_server,
|
14
|
-
%(cd #{deploy_directory}),
|
13
|
+
execute_command migration_server, prepare_environment,
|
15
14
|
%(RAILS_ENV=#{environment} bundle exec rake db:create)
|
16
15
|
else
|
17
|
-
info "
|
16
|
+
info "Setup aborted."
|
18
17
|
end
|
19
18
|
end
|
20
19
|
|
data/lib/ors/commands/update.rb
CHANGED
@@ -8,8 +8,7 @@ module ORS::Commands
|
|
8
8
|
execute_in_parallel(all_servers) {|server| update_code server }
|
9
9
|
execute_in_parallel(ruby_servers) {|server| bundle_install server }
|
10
10
|
|
11
|
-
execute_command cron_server,
|
12
|
-
%(cd #{deploy_directory}),
|
11
|
+
execute_command cron_server, prepare_environment,
|
13
12
|
%(if [ -f config/schedule.rb ]; then bundle exec whenever --update-crontab --set environment=#{environment} -i #{name}_#{environment}; fi)
|
14
13
|
end
|
15
14
|
|
data/lib/ors/helpers.rb
CHANGED
@@ -16,58 +16,54 @@ module ORS
|
|
16
16
|
def setup_ruby server
|
17
17
|
info "[#{server}] installing ruby and gems..."
|
18
18
|
|
19
|
-
execute_command server,
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
%(bundle install --without development test osx_development > bundler.log)
|
19
|
+
execute_command server, prepare_environment,
|
20
|
+
%(gem install rubygems-update),
|
21
|
+
%(gem update --system),
|
22
|
+
%(gem install bundler),
|
23
|
+
%(bundle install --without development test osx_development > bundler.log)
|
25
24
|
end
|
26
25
|
|
27
26
|
def update_code server
|
28
27
|
info "[#{server}] updating codebase..."
|
29
28
|
|
30
|
-
execute_command server,
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
execute_command server, prepare_environment,
|
30
|
+
%(git fetch),
|
31
|
+
%(git checkout -q -f origin/#{environment}),
|
32
|
+
%(git reset --hard)
|
34
33
|
end
|
35
34
|
|
36
35
|
def bundle_install server
|
37
36
|
info "[#{server}] installing bundle..."
|
38
37
|
|
39
|
-
execute_command server,
|
40
|
-
%(cd #{deploy_directory}),
|
38
|
+
execute_command server, prepare_environment,
|
41
39
|
%(bundle install --without development test osx_development > bundler.log)
|
42
40
|
end
|
43
41
|
|
44
42
|
def start_server server
|
45
43
|
info "[#{server}] starting unicorn..."
|
46
44
|
|
47
|
-
execute_command server,
|
48
|
-
%(cd #{deploy_directory}),
|
45
|
+
execute_command server, prepare_environment,
|
49
46
|
%(if [ -f config.ru ]; then RAILS_ENV=#{environment} bundle exec unicorn -c config/unicorn.rb -D -E #{environment}; else RAILS_ENV=#{environment} bundle exec unicorn_rails -c config/unicorn.rb -D -E #{environment}; fi)
|
50
47
|
end
|
51
48
|
|
52
49
|
def stop_server server
|
53
50
|
info "[#{server}] stopping unicorn..."
|
54
51
|
|
55
|
-
execute_command server,
|
52
|
+
execute_command server, prepare_environment,
|
56
53
|
%(kill \\`cat tmp/pids/unicorn.pid\\`)
|
57
54
|
end
|
58
55
|
|
59
56
|
def restart_server server
|
60
57
|
info "[#{server}] restarting unicorn..."
|
61
58
|
|
62
|
-
execute_command server,
|
59
|
+
execute_command server, prepare_environment,
|
63
60
|
%(kill -USR2 \\`cat tmp/pids/unicorn.pid\\`)
|
64
61
|
end
|
65
62
|
|
66
63
|
def run_migrations server
|
67
64
|
info "[#{server}] running migrations..."
|
68
65
|
|
69
|
-
execute_command server,
|
70
|
-
%(cd #{deploy_directory}),
|
66
|
+
execute_command server, prepare_environment,
|
71
67
|
%(RAILS_ENV=#{environment} bundle exec rake db:migrate db:seed)
|
72
68
|
end
|
73
69
|
|
@@ -131,6 +127,11 @@ module ORS
|
|
131
127
|
end
|
132
128
|
end
|
133
129
|
|
130
|
+
def prepare_environment
|
131
|
+
[%(source ~/.rvm/scripts/rvm),
|
132
|
+
%({ cd #{deploy_directory} > /dev/null; })] # Silence RVM's "Using... gemset..."
|
133
|
+
end
|
134
|
+
|
134
135
|
def info message
|
135
136
|
STDOUT.puts message
|
136
137
|
end
|
data/lib/ors/version.rb
CHANGED
@@ -6,7 +6,7 @@ describe ORS::Commands::Console do
|
|
6
6
|
it "should set pretending to true and call exec" do
|
7
7
|
stub(subject).name {'abc/growhealthy'}
|
8
8
|
stub(subject).environment {'production'}
|
9
|
-
mock(subject).execute_command(is_a(String), is_a(
|
9
|
+
mock(subject).execute_command(is_a(String), is_a(Array), is_a(String), is_a(Hash)).returns("command")
|
10
10
|
subject.execute
|
11
11
|
end
|
12
12
|
end
|
@@ -29,13 +29,13 @@ describe ORS::Commands::Runner do
|
|
29
29
|
|
30
30
|
it "should be successful with an argument to --code" do
|
31
31
|
ORS::Config.parse_options %w(--code true)
|
32
|
-
mock(subject).execute_command(is_a(String), is_a(
|
32
|
+
mock(subject).execute_command(is_a(String), is_a(Array), is_a(String), is_a(Hash)).returns("results")
|
33
33
|
lambda {subject.execute}.should_not raise_error
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should be successful with an argument to -c" do
|
37
37
|
ORS::Config.parse_options %w(-c true)
|
38
|
-
mock(subject).execute_command(is_a(String), is_a(
|
38
|
+
mock(subject).execute_command(is_a(String), is_a(Array), is_a(String), is_a(Hash)).returns("results")
|
39
39
|
lambda {subject.execute}.should_not raise_error
|
40
40
|
end
|
41
41
|
end
|
@@ -11,7 +11,7 @@ describe ORS::Commands::Update do
|
|
11
11
|
mock(subject).info /updating/
|
12
12
|
mock(subject).execute_in_parallel(:all_servers)
|
13
13
|
mock(subject).execute_in_parallel(:ruby_servers)
|
14
|
-
mock(subject).execute_command(:cron_server, is_a(
|
14
|
+
mock(subject).execute_command(:cron_server, is_a(Array), is_a(String))
|
15
15
|
|
16
16
|
subject.execute
|
17
17
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: ors
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jason Dew and John Long
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-09-
|
13
|
+
date: 2011-09-03 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|