biola_deploy 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/biola_deploy/version.rb +1 -1
- data/lib/tasks/deploy.rake +48 -29
- 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: 6eceeb81d797e4f0e7aa9aa5ffbd517808c420bd
|
4
|
+
data.tar.gz: f465f3c67964f9aab1bb1c6e099aced584837c45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a31b819c009e7b5105bd552b1dab3e218f4dde90dfbc97a259a9b2f0e7184d963ef09179bb0c52f58f3d9a20da46a878dee15851238a654e0a2892990392ccc1
|
7
|
+
data.tar.gz: 564b9248d47548025418181f62d3201b52802001f249010e95225e4d4d4f8cbc828d66b76145ab9bfe6a206d988d56c0f39f8828cef769e76918e9bdde444503
|
data/lib/biola_deploy/version.rb
CHANGED
data/lib/tasks/deploy.rake
CHANGED
@@ -1,62 +1,81 @@
|
|
1
1
|
require 'fileutils'
|
2
|
-
require 'uri'
|
3
2
|
|
4
3
|
namespace :deploy do
|
5
4
|
desc 'Run the database migrations'
|
6
|
-
task :migrate_db
|
7
|
-
|
8
|
-
|
5
|
+
task :migrate_db do
|
6
|
+
if_rails_loads 'database migration' do
|
7
|
+
Rake::Task['db:migrate'].invoke
|
8
|
+
end
|
9
9
|
end
|
10
10
|
|
11
11
|
desc 'Reindex Solr if it exists'
|
12
12
|
task :reindex_solr do
|
13
|
-
|
14
|
-
puts 'reindexing Solr...'
|
13
|
+
if_rails_loads 'Solr reindex' do
|
15
14
|
Rake::Task['sunspot:reindex'].invoke
|
16
15
|
end
|
17
16
|
end
|
18
17
|
|
19
18
|
desc 'Precompile the asset pipeline in Rails apps 3.1 and above'
|
20
19
|
task :precompile_assets do
|
21
|
-
|
22
|
-
puts 'precompiling assets...'
|
20
|
+
if_rails_loads 'asset precompile' do
|
23
21
|
Rake::Task['assets:precompile'].invoke
|
24
22
|
end
|
25
23
|
end
|
26
24
|
|
27
25
|
desc 'Tell NewRelic about this deployment'
|
28
|
-
task :tell_newrelic
|
29
|
-
|
30
|
-
|
26
|
+
task :tell_newrelic do
|
27
|
+
if_rails_loads 'NewRelic deployment' do
|
28
|
+
# TODO: check for NewRelic
|
29
|
+
require 'new_relic/cli/command'
|
30
|
+
require 'new_relic/cli/deployments'
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
version = if defined? Version
|
33
|
+
Version.current
|
34
|
+
else
|
35
|
+
`git log -1 --format=%h`.chomp # abbreviated hash of latest git commit
|
36
|
+
end
|
37
37
|
|
38
|
-
|
38
|
+
NewRelic::Cli::Deployments.new(revision: version).run
|
39
|
+
end
|
39
40
|
end
|
40
41
|
|
41
|
-
desc 'Trigger
|
42
|
-
task :restart_app
|
43
|
-
|
42
|
+
desc 'Trigger an application restart'
|
43
|
+
task :restart_app do
|
44
|
+
if_rails_loads 'application restart' do
|
45
|
+
restart_file = 'tmp/restart.txt'
|
44
46
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
47
|
+
Dir.chdir(app_dir) do
|
48
|
+
if File.exists? restart_file
|
49
|
+
FileUtils.touch restart_file
|
50
|
+
end
|
51
|
+
end
|
49
52
|
end
|
50
53
|
end
|
51
54
|
|
52
55
|
private
|
53
56
|
|
54
|
-
|
55
|
-
|
57
|
+
# If this is a first run and there is no database.yml (for instance)
|
58
|
+
# this will return false
|
59
|
+
def if_rails_loads(task_description, &block)
|
60
|
+
error = nil
|
61
|
+
|
62
|
+
unless defined?(Rails) && Rails.initialized?
|
63
|
+
begin
|
64
|
+
load 'config/environment.rb'
|
65
|
+
rescue LoadError, RuntimeError => e
|
66
|
+
error = e.message
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
if error
|
71
|
+
puts "Skipping #{task_description} because: #{error}"
|
72
|
+
else
|
73
|
+
puts "Running #{task_description}"
|
74
|
+
block.call
|
75
|
+
end
|
56
76
|
end
|
57
77
|
|
58
|
-
def
|
59
|
-
|
60
|
-
system "sudo chmod #{permissions} #{file}"
|
78
|
+
def app_dir
|
79
|
+
Rails.root.to_s
|
61
80
|
end
|
62
81
|
end
|