smartcloud 0.0.170 → 0.0.175
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/smartcloud/grids/buildpacker.rb +75 -25
- data/lib/smartcloud/grids/runner.rb +13 -7
- data/lib/smartcloud/logger.rb +2 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99e69fe0612ec14d6e92533ccd41a7a5b8d5b28a3647b5e8d406c36d62fcd35d
|
4
|
+
data.tar.gz: 8df92bc6e039ea2a09cf4f651a8694ef317c7cf2d5d143a2abda14fd619c277e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6cb0174ba73d9cbc9bc142c5dd72e67889a90a64b15325a51bf21381f9748d25d70ce8fb4e22898b4e3888f1c7facb41d3b7a520c517f69dc1000de384a9c817
|
7
|
+
data.tar.gz: 944daa53a58715fc88f28fc11fc39a910068222bbb3ea2fe5c9092bf5c4dfbe6a9f4a156239fc3167f694e48638720ab03eca1553af4630c4087d852fe51c39f
|
@@ -7,47 +7,97 @@ module Smartcloud
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def pack
|
10
|
-
|
11
|
-
"\t\t\t------> #{severity}: #{message}\n"
|
12
|
-
end
|
10
|
+
set_logger_formatter_arrow
|
13
11
|
|
14
12
|
pack_rails if File.exist? "bin/rails"
|
15
|
-
logger.info "Could not continue ... Launch Failed."
|
16
13
|
|
14
|
+
logger.error "Could not continue ... Launch Failed."
|
17
15
|
logger.formatter = nil
|
16
|
+
exit 1
|
18
17
|
end
|
19
18
|
|
20
19
|
def pack_rails
|
21
|
-
|
22
|
-
|
20
|
+
return unless bundle_install?
|
21
|
+
return unless precompile_assets?
|
22
|
+
return unless start_web_server?
|
23
23
|
|
24
|
-
|
24
|
+
exit 0
|
25
|
+
end
|
26
|
+
|
27
|
+
# Perform bundle install
|
28
|
+
def bundle_install?
|
29
|
+
logger.info ""
|
25
30
|
logger.info "Performing bundle install ..."
|
26
|
-
|
27
|
-
|
28
|
-
end
|
31
|
+
|
32
|
+
set_logger_formatter_tabs
|
29
33
|
exit_status = nil
|
30
|
-
Open3.
|
31
|
-
|
32
|
-
|
33
|
-
end
|
34
|
-
exit_status = wait_thr.value
|
34
|
+
Open3.popen2e("bundle", "install", "--deployment", "--clean") do |stdin, stdout_and_stderr, wait_thr|
|
35
|
+
stdout_and_stderr.each { |line| logger.info "#{line}" }
|
36
|
+
exit_status = wait_thr.value.success?
|
35
37
|
end
|
38
|
+
set_logger_formatter_arrow
|
36
39
|
|
37
|
-
if exit_status
|
40
|
+
if exit_status
|
41
|
+
return true
|
42
|
+
else
|
38
43
|
logger.error "Could not complete bundle install."
|
44
|
+
return false
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Perform pre-compiling of assets
|
49
|
+
def precompile_assets?
|
50
|
+
logger.info ""
|
51
|
+
logger.info "Installing Javascript dependencies & pre-compiling assets ..."
|
52
|
+
|
53
|
+
set_logger_formatter_tabs
|
54
|
+
exit_status = nil
|
55
|
+
Open3.popen2e("bundle", "exec", "rails", "assets:precompile") do |stdin, stdout_and_stderr, wait_thr|
|
56
|
+
stdout_and_stderr.each { |line| logger.info "#{line}" }
|
57
|
+
exit_status = wait_thr.value.success?
|
39
58
|
end
|
59
|
+
set_logger_formatter_arrow
|
40
60
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
61
|
+
if exit_status
|
62
|
+
return true
|
63
|
+
else
|
64
|
+
logger.error "Could not install Javascript dependencies or pre-compile assets."
|
65
|
+
return false
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# Perform starting of web server
|
70
|
+
def start_web_server?
|
71
|
+
logger.debug ""
|
72
|
+
logger.debug "Starting Web Server ..."
|
73
|
+
|
74
|
+
# Remove server.pid if it exists
|
75
|
+
FileUtils.rm("tmp/pids/server.pid") if File.exist? "tmp/pids/server.pid"
|
76
|
+
|
77
|
+
# if system("god -c Godfile -D")
|
78
|
+
logger.info ""
|
79
|
+
logger.info "Launched Application ... Success."
|
80
|
+
# return true
|
50
81
|
# end
|
82
|
+
return false
|
83
|
+
end
|
84
|
+
|
85
|
+
def set_logger_formatter_arrow
|
86
|
+
logger.formatter = proc do |severity, datetime, progname, message|
|
87
|
+
severity_text = (severity == 'INFO') ? " " : "#{severity}:"
|
88
|
+
info_symbol = "#{('\u2713').force_encoding('utf-8')}"
|
89
|
+
# error_symbol = "#{('\u274c').force_encoding('utf-8')}"
|
90
|
+
# warn_symbol = "#{('\u26a0').force_encoding('utf-8')}"
|
91
|
+
symbol_text = (severity == 'INFO') ? info_symbol : "#{severity}:"
|
92
|
+
|
93
|
+
"\t\t\t------> #{severity_text} #{message}\n"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def set_logger_formatter_tabs
|
98
|
+
logger.formatter = proc do |severity, datetime, progname, message|
|
99
|
+
"\t\t\t\t\t #{message}"
|
100
|
+
end
|
51
101
|
end
|
52
102
|
end
|
53
103
|
end
|
@@ -220,7 +220,13 @@ module Smartcloud
|
|
220
220
|
|
221
221
|
def self.prereceive_app(appname, username, oldrev, newrev, refname)
|
222
222
|
logger.formatter = proc do |severity, datetime, progname, message|
|
223
|
-
|
223
|
+
severity_text = (severity == 'INFO') ? " " : "#{severity}:"
|
224
|
+
info_symbol = "#{('\u2713').force_encoding('utf-8')}"
|
225
|
+
# error_symbol = "#{('\u274c').force_encoding('utf-8')}"
|
226
|
+
# warn_symbol = "#{('\u26a0').force_encoding('utf-8')}"
|
227
|
+
symbol_text = (severity == 'INFO') ? info_symbol : "#{severity}:"
|
228
|
+
|
229
|
+
"\t\t\t------> #{severity_text} #{message}\n"
|
224
230
|
end
|
225
231
|
|
226
232
|
# Load vars and environment
|
@@ -228,7 +234,6 @@ module Smartcloud
|
|
228
234
|
return unless self.load_container_env_vars(container_path)
|
229
235
|
|
230
236
|
# Verify the user and ensure the user is correct and has access to this repository
|
231
|
-
logger.info "Verifying User ..."
|
232
237
|
unless ENV['USERNAME'] == username
|
233
238
|
logger.error "Unauthorized."
|
234
239
|
return
|
@@ -289,6 +294,7 @@ module Smartcloud
|
|
289
294
|
end
|
290
295
|
|
291
296
|
def self.start_app_rails(appname, container_path, container_path_with_version)
|
297
|
+
logger.info ""
|
292
298
|
logger.info "Ruby on Rails application detected."
|
293
299
|
|
294
300
|
# Setup rails env
|
@@ -300,7 +306,7 @@ module Smartcloud
|
|
300
306
|
system("grep -q '^RAILS_SERVE_STATIC_FILES=' #{env_path} || echo 'RAILS_SERVE_STATIC_FILES=enabled' >> #{env_path}")
|
301
307
|
system("grep -q '^LANG=' #{env_path} || echo 'LANG=en_US.UTF-8' >> #{env_path}")
|
302
308
|
system("grep -q '^RAILS_MASTER_KEY=' #{env_path} || echo 'RAILS_MASTER_KEY=yourmasterkey' >> #{env_path}")
|
303
|
-
logger.warn "
|
309
|
+
logger.warn "Please set your RAILS_MASTER_KEY env var for this rails app." if system("grep -q '^RAILS_MASTER_KEY=yourmasterkey' #{env_path}")
|
304
310
|
|
305
311
|
# Setup gems folder. If this is not created then docker will create it while running the container,
|
306
312
|
# but the folder will have root user assigned instead of the current user.
|
@@ -308,7 +314,7 @@ module Smartcloud
|
|
308
314
|
|
309
315
|
# Setup Godfile
|
310
316
|
unless File.exist? "#{container_path_with_version}/Godfile"
|
311
|
-
logger.warn "
|
317
|
+
logger.warn "Godfile not detected. Adding a default Godfile. It is recommended to add your own Godfile."
|
312
318
|
page = <<~"HEREDOC"
|
313
319
|
God.watch do |w|
|
314
320
|
w.name = "web"
|
@@ -327,9 +333,9 @@ module Smartcloud
|
|
327
333
|
--env-file='#{container_path}/env' \
|
328
334
|
--expose='5000' \
|
329
335
|
--volume='#{Smartcloud.config.user_home_path}/.smartcloud/config:#{Smartcloud.config.user_home_path}/.smartcloud/config' \
|
330
|
-
--volume='#{container_path_with_version}:/
|
331
|
-
--volume='#{container_path}/gems:/
|
332
|
-
--workdir='/
|
336
|
+
--volume='#{container_path_with_version}:/app' \
|
337
|
+
--volume='#{container_path}/gems:/app/vendor/bundle' \
|
338
|
+
--workdir='/app' \
|
333
339
|
--restart='always' \
|
334
340
|
--network='nginx-network' \
|
335
341
|
smartcloud/buildpacks/rails", out: File::NULL)
|
data/lib/smartcloud/logger.rb
CHANGED