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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 24fd60fd7e8faf1b8fc21ed2d0258329b2963c4748a0b312c0272104045f422c
4
- data.tar.gz: 64a033c1adb9c5640bbc356d623b7e43d72d7d3508422f13479cddffeea5c24a
3
+ metadata.gz: 99e69fe0612ec14d6e92533ccd41a7a5b8d5b28a3647b5e8d406c36d62fcd35d
4
+ data.tar.gz: 8df92bc6e039ea2a09cf4f651a8694ef317c7cf2d5d143a2abda14fd619c277e
5
5
  SHA512:
6
- metadata.gz: a9136551d60c79830bfd1d9d68175a4c8181accc516d64432108af898a8cddfe30f0d8c354e8575c31bff4fbfd1701afce161ba7585dec1d9368ef434419ebdd
7
- data.tar.gz: 3132e08e01400f5bd7da3ffd9231aa15db0f26dc36df8b06eb880ae983a5d284a589a29da43e94dc2eabf561aed258357e219c63a788ac326b88fad9a171ece0
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
- logger.formatter = proc do |severity, datetime, progname, message|
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
- # Remove server.pid if it exists
22
- FileUtils.rm("tmp/pids/server.pid") if File.exist? "tmp/pids/server.pid"
20
+ return unless bundle_install?
21
+ return unless precompile_assets?
22
+ return unless start_web_server?
23
23
 
24
- # Perform bundle install
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
- logger.formatter = proc do |severity, datetime, progname, message|
27
- "\t\t\t\t#{message}"
28
- end
31
+
32
+ set_logger_formatter_tabs
29
33
  exit_status = nil
30
- Open3.popen2("bundle", "install", "--deployment", "--clean") do |stdin, stdout_andstderr, wait_thr|
31
- stdout_andstderr.each do |line|
32
- logger.info "#{line}"
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.success?
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
- # if system("bundle install --deployment --clean")
42
- # logger.info "Installing Javascript Dependencies & Pre-compiling Assets ..."
43
- # if system("bundle exec rails assets:precompile", out: File::NULL)
44
- # logger.debug "Starting Server ..."
45
- # if system("god -c Godfile -D")
46
- # logger.info "Launched Application ... Success."
47
- # end
48
- # # exit 0
49
- # end
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
- "\t\t\t------> #{severity}: #{message}\n"
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 "WARNING: Please set your RAILS_MASTER_KEY env var for this rails app." if system("grep -q '^RAILS_MASTER_KEY=yourmasterkey' #{env_path}")
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 "WARNING: Godfile not detected. Adding a default Godfile. It is recommended to add your own Godfile."
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}:/code' \
331
- --volume='#{container_path}/gems:/code/vendor/bundle' \
332
- --workdir='/code' \
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)
@@ -1,5 +1,7 @@
1
1
  require "logger"
2
2
 
3
+ $stdout.sync = true
4
+
3
5
  module Smartcloud
4
6
  module Logger
5
7
  def logger
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smartcloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.170
4
+ version: 0.0.175
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timeboard