engineyard-serverside 1.5.29.pre.timestamps2 → 1.5.30
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/engineyard-serverside.rb +0 -2
- data/lib/engineyard-serverside/cli.rb +24 -29
- data/lib/engineyard-serverside/configuration.rb +0 -4
- data/lib/engineyard-serverside/deploy.rb +35 -42
- data/lib/engineyard-serverside/deploy_hook.rb +2 -2
- data/lib/engineyard-serverside/deprecation.rb +17 -7
- data/lib/engineyard-serverside/lockfile_parser.rb +1 -1
- data/lib/engineyard-serverside/logged_output.rb +90 -0
- data/lib/engineyard-serverside/rails_asset_support.rb +5 -5
- data/lib/engineyard-serverside/server.rb +11 -8
- data/lib/engineyard-serverside/strategies/git.rb +15 -12
- data/lib/engineyard-serverside/task.rb +4 -8
- data/lib/engineyard-serverside/version.rb +1 -1
- data/spec/basic_deploy_spec.rb +9 -9
- data/spec/bundler_deploy_spec.rb +1 -1
- data/spec/custom_deploy_spec.rb +3 -3
- data/spec/deprecation_spec.rb +26 -4
- data/spec/git_strategy_spec.rb +2 -6
- data/spec/logged_output_spec.rb +55 -0
- data/spec/nodejs_deploy_spec.rb +2 -2
- data/spec/services_deploy_spec.rb +10 -9
- data/spec/spec_helper.rb +27 -35
- data/spec/sqlite3_deploy_spec.rb +1 -0
- data/spec/support/integration.rb +13 -1
- metadata +24 -27
- data/lib/engineyard-serverside/shell.rb +0 -151
- data/spec/shell_spec.rb +0 -46
@@ -9,7 +9,7 @@ module EY
|
|
9
9
|
keep_existing_assets
|
10
10
|
cmd = "cd #{c.release_path} && PATH=#{c.binstubs_path}:$PATH #{c.framework_envs} rake assets:precompile || true"
|
11
11
|
if rails_version
|
12
|
-
|
12
|
+
info "~> Precompiling assets for rails v#{rails_version}"
|
13
13
|
else
|
14
14
|
warning "Precompiling assets even though Rails was not bundled."
|
15
15
|
end
|
@@ -22,24 +22,24 @@ module EY
|
|
22
22
|
return unless File.readable?(app_rb_path) # Not a Rails app in the first place.
|
23
23
|
|
24
24
|
if File.directory?(File.join(c.release_path, 'app', 'assets'))
|
25
|
-
|
25
|
+
info "~> app/assets/ found. Attempting Rails asset pre-compilation."
|
26
26
|
else
|
27
27
|
return false
|
28
28
|
end
|
29
29
|
|
30
30
|
if app_builds_own_assets?
|
31
|
-
|
31
|
+
info "~> public/assets already exists, skipping pre-compilation."
|
32
32
|
return
|
33
33
|
end
|
34
34
|
if app_disables_assets?(app_rb_path)
|
35
|
-
|
35
|
+
info "~> application.rb has disabled asset compilation. Skipping."
|
36
36
|
return
|
37
37
|
end
|
38
38
|
# This check is very expensive, and has been deemed not worth the time.
|
39
39
|
# Leaving this here in case someone comes up with a faster way.
|
40
40
|
=begin
|
41
41
|
unless app_has_asset_task?
|
42
|
-
|
42
|
+
info "~> No 'assets:precompile' Rake task found. Skipping."
|
43
43
|
return
|
44
44
|
end
|
45
45
|
=end
|
@@ -1,8 +1,11 @@
|
|
1
1
|
require 'open-uri'
|
2
|
+
require 'engineyard-serverside/logged_output'
|
2
3
|
|
3
4
|
module EY
|
4
5
|
module Serverside
|
5
6
|
class Server < Struct.new(:hostname, :roles, :name, :user)
|
7
|
+
include LoggedOutput
|
8
|
+
|
6
9
|
class DuplicateHostname < StandardError
|
7
10
|
def initialize(hostname)
|
8
11
|
super "There is already an EY::Serverside::Server with hostname '#{hostname}'"
|
@@ -72,20 +75,20 @@ module EY
|
|
72
75
|
|
73
76
|
def sync_directory(directory)
|
74
77
|
return if local?
|
75
|
-
|
76
|
-
|
78
|
+
run "mkdir -p #{directory}"
|
79
|
+
logged_system(%|rsync --delete -aq -e "#{ssh_command}" #{directory}/ #{user}@#{hostname}:#{directory}|)
|
77
80
|
end
|
78
81
|
|
79
82
|
def run(command)
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
83
|
+
if local?
|
84
|
+
logged_system(command)
|
85
|
+
else
|
86
|
+
logged_system(ssh_command + " " + Escape.shell_command(["#{user}@#{hostname}", command]))
|
87
|
+
end
|
85
88
|
end
|
86
89
|
|
87
90
|
def ssh_command
|
88
|
-
"ssh -i #{ENV['HOME']}/.ssh/internal -o StrictHostKeyChecking=no -o PasswordAuthentication=no
|
91
|
+
"ssh -i #{ENV['HOME']}/.ssh/internal -o StrictHostKeyChecking=no -o PasswordAuthentication=no"
|
89
92
|
end
|
90
93
|
|
91
94
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'engineyard-serverside/logged_output'
|
2
|
+
|
1
3
|
module EY
|
2
4
|
module Serverside
|
3
5
|
module Strategies
|
@@ -26,7 +28,7 @@ module EY
|
|
26
28
|
#
|
27
29
|
# Rollback doesn't know about the repository location (nor
|
28
30
|
# should it need to), but it would like to use #short_log_message.
|
29
|
-
klass.new(
|
31
|
+
klass.new(
|
30
32
|
:repository_cache => c[:repository_cache],
|
31
33
|
:app => c[:app],
|
32
34
|
:repo => c[:repo],
|
@@ -35,10 +37,11 @@ module EY
|
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
38
|
-
|
40
|
+
include LoggedOutput
|
41
|
+
|
42
|
+
attr_reader :opts
|
39
43
|
|
40
|
-
def initialize(
|
41
|
-
@shell = shell
|
44
|
+
def initialize(opts)
|
42
45
|
@opts = opts
|
43
46
|
end
|
44
47
|
|
@@ -48,21 +51,21 @@ module EY
|
|
48
51
|
|
49
52
|
def fetch
|
50
53
|
if usable_repository?
|
51
|
-
|
54
|
+
logged_system("#{git} fetch -q origin 2>&1")
|
52
55
|
else
|
53
56
|
FileUtils.rm_rf(opts[:repository_cache])
|
54
|
-
|
57
|
+
logged_system("git clone -q #{opts[:repo]} #{opts[:repository_cache]} 2>&1")
|
55
58
|
end
|
56
59
|
end
|
57
60
|
|
58
61
|
def checkout
|
59
|
-
|
62
|
+
info "~> Deploying revision #{short_log_message(to_checkout)}"
|
60
63
|
in_git_work_tree do
|
61
|
-
(
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
64
|
+
(logged_system("git checkout -q '#{to_checkout}'") ||
|
65
|
+
logged_system("git reset -q --hard '#{to_checkout}'")) &&
|
66
|
+
logged_system("git submodule sync") &&
|
67
|
+
logged_system("git submodule update --init") &&
|
68
|
+
logged_system("git clean -dfq")
|
66
69
|
end
|
67
70
|
end
|
68
71
|
|
@@ -1,16 +1,12 @@
|
|
1
|
-
require 'engineyard-serverside/shell'
|
2
|
-
|
3
1
|
module EY
|
4
2
|
module Serverside
|
5
3
|
class Task
|
6
|
-
include EY::Serverside::Shell::Helpers
|
7
4
|
|
8
|
-
attr_reader :config
|
5
|
+
attr_reader :config
|
9
6
|
alias :c :config
|
10
7
|
|
11
|
-
def initialize(conf
|
8
|
+
def initialize(conf)
|
12
9
|
@config = conf
|
13
|
-
@shell = shell
|
14
10
|
@roles = :all
|
15
11
|
end
|
16
12
|
|
@@ -22,7 +18,7 @@ module EY
|
|
22
18
|
end
|
23
19
|
|
24
20
|
if deploy_file
|
25
|
-
|
21
|
+
puts "~> Loading deployment task overrides from #{deploy_file}"
|
26
22
|
instance_eval(File.read(deploy_file))
|
27
23
|
true
|
28
24
|
else
|
@@ -58,7 +54,7 @@ module EY
|
|
58
54
|
servers = EY::Serverside::Server.from_roles(@roles)
|
59
55
|
futures = EY::Serverside::Future.call(servers, block_given?) do |server, exec_block|
|
60
56
|
to_run = exec_block ? block.call(server, cmd.dup) : cmd
|
61
|
-
server.run(Escape.shell_command(wrapper + [to_run]))
|
57
|
+
server.run(Escape.shell_command(wrapper + [to_run]))
|
62
58
|
end
|
63
59
|
|
64
60
|
unless EY::Serverside::Future.success?(futures)
|
data/spec/basic_deploy_spec.rb
CHANGED
@@ -12,17 +12,17 @@ describe "Deploying an application without Bundler" do
|
|
12
12
|
|
13
13
|
# run a deploy
|
14
14
|
config = EY::Serverside::Deploy::Configuration.new({
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
15
|
+
"strategy" => "IntegrationSpec",
|
16
|
+
"deploy_to" => @deploy_dir.to_s,
|
17
|
+
"group" => `id -gn`.strip,
|
18
|
+
"stack" => 'nginx_passenger',
|
19
|
+
"migrate" => nil,
|
20
|
+
'app' => 'foo',
|
21
|
+
'framework_env' => 'staging'
|
22
|
+
})
|
23
23
|
|
24
24
|
@binpath = File.expand_path(File.join(File.dirname(__FILE__), '..', 'bin', 'engineyard-serverside'))
|
25
|
-
@deployer = FullTestDeploy.new(config
|
25
|
+
@deployer = FullTestDeploy.new(config)
|
26
26
|
@deployer.deploy
|
27
27
|
end
|
28
28
|
|
data/spec/bundler_deploy_spec.rb
CHANGED
@@ -32,7 +32,7 @@ describe "Deploying an application that uses Bundler" do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
@binpath = File.expand_path(File.join(File.dirname(__FILE__), '..', 'bin', 'engineyard-serverside'))
|
35
|
-
@deployer = FullTestDeploy.new(config
|
35
|
+
@deployer = FullTestDeploy.new(config)
|
36
36
|
@deployer.deploy
|
37
37
|
end
|
38
38
|
|
data/spec/custom_deploy_spec.rb
CHANGED
@@ -34,7 +34,7 @@ describe "the EY::Serverside::Deploy API" do
|
|
34
34
|
def disable_maintenance_page() @call_order << 'disable_maintenance_page' end
|
35
35
|
end
|
36
36
|
|
37
|
-
td = TestDeploy.new(EY::Serverside::Deploy::Configuration.new
|
37
|
+
td = TestDeploy.new(EY::Serverside::Deploy::Configuration.new)
|
38
38
|
td.deploy
|
39
39
|
td.call_order.should == %w(
|
40
40
|
push_code
|
@@ -60,7 +60,7 @@ describe "the EY::Serverside::Deploy API" do
|
|
60
60
|
before(:each) do
|
61
61
|
@tempdir = `mktemp -d -t custom_deploy_spec.XXXXX`.strip
|
62
62
|
@config = EY::Serverside::Deploy::Configuration.new('repository_cache' => @tempdir)
|
63
|
-
@deploy = TestQuietDeploy.new(@config
|
63
|
+
@deploy = TestQuietDeploy.new(@config)
|
64
64
|
end
|
65
65
|
|
66
66
|
def write_eydeploy(relative_path, contents = "def got_new_methods() 'from the file on disk' end")
|
@@ -92,7 +92,7 @@ describe "the EY::Serverside::Deploy API" do
|
|
92
92
|
def value() 'base' end
|
93
93
|
end
|
94
94
|
|
95
|
-
deploy = TestDeploySuper.new(@config
|
95
|
+
deploy = TestDeploySuper.new(@config)
|
96
96
|
deploy.require_custom_tasks.should be_true
|
97
97
|
deploy.value.should == "base + derived"
|
98
98
|
end
|
data/spec/deprecation_spec.rb
CHANGED
@@ -12,12 +12,34 @@ describe EY::Serverside do
|
|
12
12
|
$stderr = @original_stderr
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
EY::Serverside::
|
17
|
-
|
15
|
+
def check_deprecation(new_const, prints_warning = true)
|
16
|
+
old_name = new_const.to_s.gsub('EY::Serverside::', 'EY::')
|
17
|
+
eval(old_name).should == new_const
|
18
|
+
@warnings.string.should include(old_name) if prints_warning
|
19
|
+
end
|
20
|
+
|
21
|
+
it "preserves the old constants" do
|
22
|
+
names = %w[CLI Deploy DeployBase Deploy::Configuration
|
23
|
+
DeployHook LockfileParser LoggedOutput Server Task
|
24
|
+
Strategies Strategies::Git]
|
25
|
+
|
26
|
+
names.map do |name|
|
27
|
+
const = eval("::EY::Serverside::#{name}")
|
28
|
+
# The way deprecations are implemented currently, we don't print
|
29
|
+
# warning messages for constants that aren't directly under EY::
|
30
|
+
prints_warning = name.include?('::') ? false : true
|
31
|
+
check_deprecation(const, prints_warning)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it "deprecates EY.dna_json and EY.node" do
|
36
|
+
EY.dna_json.should == EY::Serverside.dna_json
|
37
|
+
@warnings.string.should include("EY.dna_json")
|
38
|
+
EY.node.should == EY::Serverside.node
|
39
|
+
@warnings.string.should include("EY.node")
|
18
40
|
end
|
19
41
|
|
20
42
|
it "doesn't interfere with unrelated constants" do
|
21
|
-
lambda{ EY::
|
43
|
+
lambda{ EY::WTFNotDefined }.should raise_error(NameError, /uninitialized constant.*EY::WTFNotDefined/)
|
22
44
|
end
|
23
45
|
end
|
data/spec/git_strategy_spec.rb
CHANGED
@@ -2,12 +2,8 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe "the git deploy strategy" do
|
4
4
|
subject do
|
5
|
-
EY::Serverside::Strategies::Git.new(
|
6
|
-
|
7
|
-
:repo => File.join(GITREPO_DIR, 'git'),
|
8
|
-
:repository_cache => GITREPO_DIR,
|
9
|
-
:ref => "master"
|
10
|
-
)
|
5
|
+
EY::Serverside::Strategies::Git.new(:repo => File.join(GITREPO_DIR, 'git'),
|
6
|
+
:repository_cache => GITREPO_DIR, :ref => "master")
|
11
7
|
end
|
12
8
|
|
13
9
|
before { subject.checkout }
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'tempfile'
|
3
|
+
require 'timecop'
|
4
|
+
|
5
|
+
class SampleLogUser
|
6
|
+
include EY::Serverside::LoggedOutput
|
7
|
+
def initialize
|
8
|
+
EY::Serverside::LoggedOutput.logfile = tempfile.path
|
9
|
+
EY::Serverside::LoggedOutput.verbose = true
|
10
|
+
end
|
11
|
+
|
12
|
+
def starting_time
|
13
|
+
@starting_time ||= Time.now
|
14
|
+
end
|
15
|
+
|
16
|
+
def tempfile
|
17
|
+
@tempfile ||= Tempfile.new('logged_output')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe EY::Serverside::LoggedOutput do
|
22
|
+
before do
|
23
|
+
EY::Serverside::LoggedOutput.enable_actual_info!
|
24
|
+
@log_user = SampleLogUser.new
|
25
|
+
end
|
26
|
+
|
27
|
+
after do
|
28
|
+
EY::Serverside::LoggedOutput.disable_actual_info!
|
29
|
+
end
|
30
|
+
|
31
|
+
it "has a timestamp before each line" do
|
32
|
+
time1 = Time.local(2008, 9, 1, 12, 0, 0)
|
33
|
+
time2 = Time.local(2008, 9, 1, 12, 3, 5)
|
34
|
+
time3 = Time.local(2008, 9, 1, 12, 10, 25)
|
35
|
+
|
36
|
+
Timecop.freeze(time1) do
|
37
|
+
@log_user.debug('test1')
|
38
|
+
@log_user.warning('test2')
|
39
|
+
end
|
40
|
+
Timecop.freeze(time2) do
|
41
|
+
@log_user.info('test3')
|
42
|
+
|
43
|
+
@log_user.debug("test11\ntest12\ntest13")
|
44
|
+
@log_user.warning("test21\ntest22\ntest23")
|
45
|
+
end
|
46
|
+
Timecop.freeze(time3) do
|
47
|
+
@log_user.info("test31\ntest32\ntest33")
|
48
|
+
end
|
49
|
+
|
50
|
+
timestamp_1 = "+ 0m 00s "
|
51
|
+
timestamp_2 = "+ 3m 05s "
|
52
|
+
timestamp_3 = "+10m 25s "
|
53
|
+
File.read(@log_user.tempfile.path).should == "#{timestamp_1}test1\n#{timestamp_1}!> WARNING: test2\n\n#{timestamp_2}test3\n#{timestamp_2}test11\n#{timestamp_2}test12\n#{timestamp_2}test13\n#{timestamp_2}!> WARNING: test21\n#{timestamp_2}!> test22\n#{timestamp_2}!> test23\n\n#{timestamp_3}test31\n#{timestamp_3}test32\n#{timestamp_3}test33\n"
|
54
|
+
end
|
55
|
+
end
|
data/spec/nodejs_deploy_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe "Deploying an application that uses Node.js and NPM" do
|
4
4
|
def deploy_test_application
|
5
|
-
@deploy_dir =
|
5
|
+
@deploy_dir = File.join(Dir.tmpdir, "serverside-deploy-#{Time.now.to_i}-#{$$}")
|
6
6
|
|
7
7
|
# set up EY::Serverside::Server like we're on a solo
|
8
8
|
EY::Serverside::Server.reset
|
@@ -19,7 +19,7 @@ describe "Deploying an application that uses Node.js and NPM" do
|
|
19
19
|
})
|
20
20
|
|
21
21
|
@binpath = File.expand_path(File.join(File.dirname(__FILE__), '..', 'bin', 'engineyard-serverside'))
|
22
|
-
@deployer = FullTestDeploy.new(config
|
22
|
+
@deployer = FullTestDeploy.new(config)
|
23
23
|
@deployer.deploy do
|
24
24
|
FileUtils.mkdir_p(config.repository_cache) # block runs before deploy
|
25
25
|
@deployer.generate_package_json_in(config.repository_cache)
|
@@ -23,8 +23,9 @@ describe "Deploying an application with services" do
|
|
23
23
|
'framework_env' => 'staging'
|
24
24
|
})
|
25
25
|
|
26
|
+
EY::Serverside::LoggedOutput.verbose = true
|
26
27
|
@binpath = File.expand_path(File.join(File.dirname(__FILE__), '..', 'bin', 'engineyard-serverside'))
|
27
|
-
FullTestDeploy.new(config
|
28
|
+
FullTestDeploy.new(config)
|
28
29
|
end
|
29
30
|
|
30
31
|
def exist
|
@@ -64,7 +65,7 @@ DEPENDENCIES
|
|
64
65
|
end
|
65
66
|
|
66
67
|
it "warns about missing ey_config" do
|
67
|
-
|
68
|
+
@deployer.infos.should be_any { |info| info =~ /WARNING: Gemfile.lock does not contain ey_config/ }
|
68
69
|
end
|
69
70
|
|
70
71
|
end
|
@@ -74,7 +75,7 @@ DEPENDENCIES
|
|
74
75
|
end
|
75
76
|
|
76
77
|
it "works without warnings" do
|
77
|
-
|
78
|
+
@deployer.infos.should_not be_any { |info| info =~ /WARNING/ }
|
78
79
|
end
|
79
80
|
|
80
81
|
end
|
@@ -100,7 +101,7 @@ DEPENDENCIES
|
|
100
101
|
@symlinked_services_file.should be_symlink
|
101
102
|
@shared_services_file.read.should == "#{@invalid_services_yml}\n"
|
102
103
|
|
103
|
-
|
104
|
+
@deployer.infos.should_not be_any { |info| info =~ /WARNING/ }
|
104
105
|
end
|
105
106
|
end
|
106
107
|
|
@@ -124,7 +125,7 @@ DEPENDENCIES
|
|
124
125
|
@symlinked_services_file.should be_symlink
|
125
126
|
@shared_services_file.read.should == "#{@services_yml}\n"
|
126
127
|
|
127
|
-
|
128
|
+
@deployer.infos.should_not be_any { |info| info =~ /WARNING/ }
|
128
129
|
end
|
129
130
|
|
130
131
|
describe "followed by a deploy that can't find the command" do
|
@@ -143,7 +144,7 @@ DEPENDENCIES
|
|
143
144
|
@symlinked_services_file.should be_symlink
|
144
145
|
@shared_services_file.read.should == "#{@services_yml}\n"
|
145
146
|
|
146
|
-
|
147
|
+
@deployer.infos.should_not be_any { |info| info =~ /WARNING/ }
|
147
148
|
end
|
148
149
|
|
149
150
|
end
|
@@ -165,7 +166,7 @@ DEPENDENCIES
|
|
165
166
|
@symlinked_services_file.should be_symlink
|
166
167
|
@shared_services_file.read.should == "#{@services_yml}\n"
|
167
168
|
|
168
|
-
|
169
|
+
@deployer.infos.should be_any { |info| info =~ /WARNING: External services configuration not updated/ }
|
169
170
|
end
|
170
171
|
|
171
172
|
it "does not log a warning or symlink a config file when there is no existing services file" do
|
@@ -175,7 +176,7 @@ DEPENDENCIES
|
|
175
176
|
@shared_services_file.should_not exist
|
176
177
|
@symlinked_services_file.should_not exist
|
177
178
|
|
178
|
-
|
179
|
+
@deployer.infos.should_not be_any { |info| info =~ /WARNING/ }
|
179
180
|
end
|
180
181
|
|
181
182
|
end
|
@@ -198,7 +199,7 @@ DEPENDENCIES
|
|
198
199
|
@symlinked_services_file.should be_symlink
|
199
200
|
@shared_services_file.read.should == "#{@services_yml}\n"
|
200
201
|
|
201
|
-
|
202
|
+
@deployer.infos.should_not be_any { |info| info =~ /WARNING/ }
|
202
203
|
end
|
203
204
|
|
204
205
|
end
|