smartcloud 0.1.0.beta3 → 0.1.0.rc3
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: 1bc0f44f2fa9ea9d6145f30db4d8c96a143e839801e8f821df13fbaa533cb2b3
|
4
|
+
data.tar.gz: 51bd95740b92513e81ab404007a7b5544c98285b956ad08f445614e4ab938b12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cce759ba90e0745bbff91afdd1a470564ca272b59bbee308dcb0f7cd9a36dc0094d6e565ba9bda11ca96fb4df7721bccfce42d60811da2c79566933025b8afe5
|
7
|
+
data.tar.gz: a3d9b46b5566bc8bbad7db19e3e4c3e9bea6ac005e2a17f734349ef6a70870a85c324cd43b617c0bd4b32f008c290e605abc6642aac42c44183f5db6bf7ad913
|
@@ -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")
|
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("#{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.rc3
|
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
|