smartcloud 0.1.0.beta4 → 0.1.0.rc4
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1794aa20175c247580a192b55b7a35a3fe06beb53c34d43976db4f7956ed7d3d
|
4
|
+
data.tar.gz: c369d0bd11bfe758349901c32310ed74c73fec943d16d44ab44ebbdf4f8d8c27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b97865250155b0797e319b697b47ee37d1e961118f112c61aa540dc4f459f7dde2d75b3042cafcb0b29a255a475dd28a878eabd2f1817cda502e65b7ca18c993
|
7
|
+
data.tar.gz: c7d05795219cde5f68ad0e33766d607a1ce90226a8d08715033555789a06ae3fe5d1c63764d90b8d4b83f5a6c7b207e4fd515e14d2e2a992d181e11bc2abf4a8
|
@@ -17,11 +17,20 @@ module Smartcloud
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def pack_rails
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
if File.exist? "tmp/smartcloud/packed"
|
21
|
+
begin
|
22
|
+
pid = File.read('tmp/smartcloud/packed').to_i
|
23
|
+
Process.kill('QUIT', pid)
|
24
|
+
rescue Errno::ESRCH # No such process
|
25
|
+
end
|
26
|
+
exec "bundle", "exec", "puma", "--config", "config/puma.rb"
|
27
|
+
else
|
28
|
+
return unless bundle_install?
|
29
|
+
return unless precompile_assets?
|
30
|
+
return unless test_web_server?
|
23
31
|
|
24
|
-
|
32
|
+
exit 0
|
33
|
+
end
|
25
34
|
end
|
26
35
|
|
27
36
|
# Perform bundle install
|
@@ -64,17 +73,34 @@ module Smartcloud
|
|
64
73
|
end
|
65
74
|
end
|
66
75
|
|
67
|
-
# Perform
|
68
|
-
def
|
69
|
-
logger.
|
70
|
-
|
71
|
-
#
|
72
|
-
FileUtils.
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
+
# Perform testing of web server
|
77
|
+
def test_web_server?
|
78
|
+
logger.info "Setting up Web Server ..."
|
79
|
+
|
80
|
+
# tmp folder
|
81
|
+
FileUtils.mkdir_p("tmp/smartcloud")
|
82
|
+
FileUtils.rm_f("tmp/smartcloud/packed")
|
83
|
+
|
84
|
+
# Spawn Process
|
85
|
+
pid = Process.spawn("bundle", "exec", "puma", "--config", "config/puma.rb", out: File::NULL)
|
86
|
+
Process.detach(pid)
|
87
|
+
|
88
|
+
# Sleep
|
89
|
+
sleep 5
|
90
|
+
|
91
|
+
# Check PID running
|
92
|
+
status = nil
|
93
|
+
begin
|
94
|
+
Process.kill(0, pid)
|
95
|
+
system("echo '#{pid}' > tmp/smartcloud/packed")
|
96
|
+
status = true
|
97
|
+
rescue Errno::ESRCH # No such process
|
98
|
+
logger.info "Web Server could not start"
|
99
|
+
status = false
|
76
100
|
end
|
77
|
-
|
101
|
+
|
102
|
+
# Return status
|
103
|
+
return status
|
78
104
|
end
|
79
105
|
|
80
106
|
def set_logger_formatter_arrow
|
@@ -293,6 +293,7 @@ module Smartcloud
|
|
293
293
|
# Setup rails env
|
294
294
|
env_path = "#{container_path}/env"
|
295
295
|
system("grep -q '^## Rails' #{env_path} || echo '## Rails' >> #{env_path}")
|
296
|
+
system("grep -q '^MALLOC_ARENA_MAX=' #{env_path} || echo '# MALLOC_ARENA_MAX=2' >> #{env_path}")
|
296
297
|
system("grep -q '^RAILS_ENV=' #{env_path} || echo 'RAILS_ENV=production' >> #{env_path}")
|
297
298
|
system("grep -q '^RACK_ENV=' #{env_path} || echo 'RACK_ENV=production' >> #{env_path}")
|
298
299
|
system("grep -q '^RAILS_LOG_TO_STDOUT=' #{env_path} || echo 'RAILS_LOG_TO_STDOUT=enabled' >> #{env_path}")
|
@@ -307,20 +308,6 @@ module Smartcloud
|
|
307
308
|
FileUtils.mkdir_p("#{container_path}/app/public")
|
308
309
|
FileUtils.mkdir_p("#{container_path}/app/node_modules")
|
309
310
|
|
310
|
-
# Setup Godfile
|
311
|
-
unless File.exist? "#{container_path_with_version}/Godfile"
|
312
|
-
logger.warn "Godfile not detected. Adding a default Godfile. It is recommended to add your own Godfile."
|
313
|
-
page = <<~"HEREDOC"
|
314
|
-
God.watch do |w|
|
315
|
-
w.name = "web"
|
316
|
-
w.start = "bundle exec puma -C config/puma.rb"
|
317
|
-
w.behavior(:clean_pid_file)
|
318
|
-
w.keepalive
|
319
|
-
end
|
320
|
-
HEREDOC
|
321
|
-
system("echo '#{page}' > #{container_path_with_version}/Godfile")
|
322
|
-
end
|
323
|
-
|
324
311
|
# Creating & Starting container
|
325
312
|
container_id = `docker ps -a -q --filter='name=^#{appname}_1$' --filter='status=running'`.chomp
|
326
313
|
new_container = container_id.empty? ? "#{appname}_1" : "#{appname}_2"
|
@@ -330,13 +317,14 @@ module Smartcloud
|
|
330
317
|
if system("docker create \
|
331
318
|
--name='#{new_container}' \
|
332
319
|
--env-file='#{container_path}/env' \
|
333
|
-
--expose='
|
320
|
+
--expose='3000' \
|
334
321
|
--volume='#{Smartcloud.config.user_home_path}/.smartcloud/config:#{Smartcloud.config.user_home_path}/.smartcloud/config' \
|
335
322
|
--volume='#{container_path_with_version}:/app' \
|
336
323
|
--volume='#{container_path}/app/vendor/bundle:/app/vendor/bundle' \
|
337
324
|
--volume='#{container_path}/app/public:/app/public' \
|
338
325
|
--volume='#{container_path}/app/node_modules:/app/node_modules' \
|
339
326
|
--restart='always' \
|
327
|
+
--init \
|
340
328
|
--network='nginx-network' \
|
341
329
|
smartcloud/buildpacks/rails", out: File::NULL)
|
342
330
|
|
@@ -344,10 +332,15 @@ module Smartcloud
|
|
344
332
|
system("docker network connect mysql-network #{new_container}")
|
345
333
|
|
346
334
|
if system("docker start --attach #{new_container}")
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
335
|
+
logger.debug "Starting Web Server ..."
|
336
|
+
if system("docker start #{new_container}")
|
337
|
+
sleep 5
|
338
|
+
puts "Web Server started successfully."
|
339
|
+
self.stop_app(old_container)
|
340
|
+
self.clean_up(container_path)
|
341
|
+
logger.info "Launched Application ... Success."
|
342
|
+
exit 10
|
343
|
+
end
|
351
344
|
else
|
352
345
|
self.stop_app("#{new_container}")
|
353
346
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smartcloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.rc4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Timeboard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|