immosquare-capistrano 0.1.5 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d5ce30da4725609f237136b6fa05c3cae9668c128a9c10c7db824c26564df61
|
4
|
+
data.tar.gz: 7135f08dfb35aa6a54eda7c03ad8825df43c2f7aea822a813eb4a0fc161d67c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91ffa7cba4f9af474bd1ae3a77f83199e740f49e44149f805fb8734759664b389ac13ec6ff9a686545810710c4d0673ac789e10bcae84aba9ae9bd7c2b2eab3c
|
7
|
+
data.tar.gz: ffe745d0bb6d5ad2c4570c3064e84a8ac0ce345feb938854a7ffcd5ed94f79df1c9b0de9236fa6528338bb6ac1c5e8cbb704f09dc6b719a51f6d420d1d6c6209
|
@@ -14,11 +14,5 @@ namespace :load do
|
|
14
14
|
## SolidQueue
|
15
15
|
##============================================================##
|
16
16
|
set_if_empty :solid_queue_service_unit_name, -> { "solid_queue_#{fetch(:application)}_#{fetch(:stage)}" }
|
17
|
-
|
18
|
-
##============================================================##
|
19
|
-
## rvm
|
20
|
-
##============================================================##
|
21
|
-
set_if_empty :rvm_ruby_version, -> { "default" }
|
22
|
-
set_if_empty :rvm_map_bins, -> { ["gem", "rake", "ruby", "bundle"] }
|
23
17
|
end
|
24
18
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require_relative "defaults"
|
2
2
|
|
3
|
-
|
4
3
|
##============================================================##
|
5
4
|
## We load rvm tasks
|
6
5
|
##============================================================##
|
@@ -13,5 +12,9 @@ load File.expand_path("tasks/rvm.rake", __dir__)
|
|
13
12
|
##============================================================##
|
14
13
|
Capistrano::DSL.stages.each do |stage|
|
15
14
|
after stage, "rvm:hook"
|
16
|
-
# after stage, "rvm:check"
|
17
15
|
end
|
16
|
+
|
17
|
+
##============================================================##
|
18
|
+
## Update .ruby-gemset && ruby-version files
|
19
|
+
##============================================================##
|
20
|
+
before "deploy:updated", "rvm:update_rvm_dot_files"
|
@@ -13,25 +13,89 @@ namespace :rvm do
|
|
13
13
|
elsif test("[ -d #{rvm_system_path} ]")
|
14
14
|
rvm_system_path
|
15
15
|
else
|
16
|
-
|
16
|
+
error("RVM path not found on server. Please install RVM first")
|
17
|
+
exit(1)
|
17
18
|
end
|
19
|
+
info "RVM path detected: #{rvm_path}"
|
20
|
+
rvm_bin_path = "#{rvm_path}/bin/rvm"
|
18
21
|
|
19
22
|
##============================================================##
|
20
|
-
##
|
23
|
+
## Set the RVM command map
|
21
24
|
##============================================================##
|
22
|
-
|
23
|
-
|
25
|
+
SSHKit.config.command_map[:rvm] = rvm_bin_path
|
24
26
|
|
25
27
|
##============================================================##
|
26
|
-
##
|
28
|
+
## Check if the RVM Ruby version is set
|
27
29
|
##============================================================##
|
28
|
-
|
30
|
+
rvm_ruby_version = fetch(:rvm_ruby_version)
|
31
|
+
if rvm_ruby_version.nil?
|
32
|
+
error "rvm_ruby_version not set. Please set the rvm_ruby_version in your deploy.rb file with format ruby-x.y.z@your-app-name"
|
33
|
+
exit 1
|
34
|
+
elsif rvm_ruby_version !~ /^ruby-\d+\.\d+\.\d+@[a-z0-9\-_]+$/i
|
35
|
+
error "rvm_ruby_version format is invalid. Please set the rvm_ruby_version in your deploy.rb file with format ruby-x.y.z@your-app-name"
|
36
|
+
exit 1
|
37
|
+
end
|
38
|
+
info "rvm_ruby_version set: #{rvm_ruby_version}"
|
29
39
|
|
30
40
|
##============================================================##
|
31
41
|
## Set the RVM prefix for the commands
|
32
42
|
##============================================================##
|
33
|
-
|
34
|
-
SSHKit.config.command_map.prefix[command.to_sym].unshift("#{
|
43
|
+
["gem", "rake", "ruby", "bundle"].each do |command|
|
44
|
+
SSHKit.config.command_map.prefix[command.to_sym].unshift("#{rvm_bin_path} #{rvm_ruby_version} do")
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
##============================================================##
|
49
|
+
## Check if ruby version is installed
|
50
|
+
##============================================================##
|
51
|
+
ruby_version = rvm_ruby_version.split("@").first
|
52
|
+
unless test("#{rvm_bin_path} #{ruby_version} do ruby --version")
|
53
|
+
error "Ruby version #{ruby_version} is not installed on the server. Please install it first with 'rvm install #{ruby_version}'"
|
54
|
+
exit 1
|
55
|
+
end
|
56
|
+
info "#{ruby_version} is installed on the server."
|
57
|
+
|
58
|
+
##============================================================##
|
59
|
+
## Check if gemset exists, if not create it
|
60
|
+
##============================================================##
|
61
|
+
gemset_name = rvm_ruby_version.split("@").last
|
62
|
+
unless test("#{rvm_bin_path} #{rvm_ruby_version} do rvm gemset list | grep -wq #{gemset_name}")
|
63
|
+
info "Creating gemset #{gemset_name} for #{ruby_version}"
|
64
|
+
execute :rvm, "#{ruby_version} do rvm gemset create #{gemset_name}"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
##============================================================##
|
70
|
+
## Update .ruby-gemset and .ruby-version files with
|
71
|
+
## values from the rvm_ruby_version variable
|
72
|
+
##============================================================##
|
73
|
+
task :update_rvm_dot_files do
|
74
|
+
on roles(:app) do
|
75
|
+
rvm_ruby_version = fetch(:rvm_ruby_version)
|
76
|
+
ruby_version = rvm_ruby_version.split("@").first
|
77
|
+
gemset_name = rvm_ruby_version.split("@").last
|
78
|
+
|
79
|
+
info "Updating .ruby-version file with #{ruby_version}"
|
80
|
+
info "Updating .ruby-gemset file with #{gemset_name}"
|
81
|
+
|
82
|
+
##============================================================##
|
83
|
+
## Mettre à jour les fichiers dans `release_path`
|
84
|
+
## The gem capistrano-bundler launch
|
85
|
+
## bundle config --local deployment true with the release_path
|
86
|
+
##============================================================##
|
87
|
+
within release_path do
|
88
|
+
execute :echo, ruby_version.to_s, ">", ".ruby-version"
|
89
|
+
execute :echo, gemset_name.to_s, ">", ".ruby-gemset"
|
90
|
+
end
|
91
|
+
|
92
|
+
##============================================================##
|
93
|
+
## To have the same version in the current path to lauch
|
94
|
+
## bundle exec commands from the current path
|
95
|
+
##============================================================##
|
96
|
+
within current_path do
|
97
|
+
execute :echo, ruby_version.to_s, ">", ".ruby-version"
|
98
|
+
execute :echo, gemset_name.to_s, ">", ".ruby-gemset"
|
35
99
|
end
|
36
100
|
end
|
37
101
|
end
|