stable-cli-rails 0.6.1 → 0.6.3
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/stable/cli.rb +13 -9
- 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: 3218e61a2bbc965b952621aadbd8eefdbe1c3d982b4a7467de087700201f7823
|
|
4
|
+
data.tar.gz: 1a401494bec7fd015c4dd21d019b39cdec1cbbd369c6cac0087f27ebf3320b70
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b7b529c7cb295c17b48104fc192af9925f1539c69a587195a3963747822f6a903846a2603242834c762ca496638b2d9f2755ca1152038d29353fb282833bd7c1
|
|
7
|
+
data.tar.gz: edcd4067681759d297021c6b845ca679c39c64af782ccfcbb290c33a4d61e4d9c23d825d3d5d8cc694d01b265e1d90c0cf4435bc32e0b83dedafe3f18d767018
|
data/lib/stable/cli.rb
CHANGED
|
@@ -71,14 +71,17 @@ module Stable
|
|
|
71
71
|
ensure_caddy_running!
|
|
72
72
|
caddy_reload
|
|
73
73
|
|
|
74
|
+
puts 'Preparing database...'
|
|
75
|
+
system("bash -lc 'rvm #{ruby}@#{name} do cd #{app_path} && bundle exec rails db:prepare'")
|
|
76
|
+
|
|
74
77
|
# --- Start Rails server ---
|
|
75
78
|
puts "Starting Rails server for #{name} on port #{port}..."
|
|
76
79
|
log_file = File.join(app_path, 'log', 'stable.log')
|
|
77
80
|
FileUtils.mkdir_p(File.dirname(log_file))
|
|
78
|
-
pid = spawn("bash -lc 'rvm #{ruby}@#{name} do cd #{app_path} && bundle exec rails s -p #{port} >> #{log_file} 2>&1'")
|
|
81
|
+
pid = spawn("bash -lc 'rvm #{ruby}@#{name} do cd #{app_path} && RAILS_ENV=development bundle exec rails s -p #{port} >> #{log_file} 2>&1'")
|
|
79
82
|
Process.detach(pid)
|
|
80
83
|
|
|
81
|
-
wait_for_port(port)
|
|
84
|
+
wait_for_port(port, timeout: 15)
|
|
82
85
|
puts "✔ #{name} running at https://#{domain}"
|
|
83
86
|
end
|
|
84
87
|
|
|
@@ -174,7 +177,7 @@ module Stable
|
|
|
174
177
|
|
|
175
178
|
cmd = <<~CMD
|
|
176
179
|
cd #{app[:path]} &&
|
|
177
|
-
#{ruby_exec} bundle exec rails s -p #{port}
|
|
180
|
+
#{ruby_exec} RAILS_ENV=development bundle exec rails s -p #{port}
|
|
178
181
|
CMD
|
|
179
182
|
|
|
180
183
|
pid = spawn(
|
|
@@ -189,7 +192,7 @@ module Stable
|
|
|
189
192
|
|
|
190
193
|
generate_cert(app[:domain])
|
|
191
194
|
update_caddyfile(app[:domain], port)
|
|
192
|
-
wait_for_port(port)
|
|
195
|
+
wait_for_port(port, timeout: 15)
|
|
193
196
|
caddy_reload
|
|
194
197
|
|
|
195
198
|
puts "#{name} started on https://#{app[:domain]}"
|
|
@@ -476,16 +479,17 @@ module Stable
|
|
|
476
479
|
end
|
|
477
480
|
end
|
|
478
481
|
|
|
479
|
-
def wait_for_port(port, timeout:
|
|
482
|
+
def wait_for_port(port, timeout: 15)
|
|
480
483
|
require 'socket'
|
|
481
|
-
|
|
484
|
+
start = Time.now
|
|
485
|
+
|
|
482
486
|
loop do
|
|
483
487
|
TCPSocket.new('127.0.0.1', port).close
|
|
484
|
-
|
|
488
|
+
return true
|
|
485
489
|
rescue Errno::ECONNREFUSED
|
|
486
|
-
raise "
|
|
490
|
+
raise "Rails failed to start on port #{port} within #{timeout}s" if Time.now - start > timeout
|
|
487
491
|
|
|
488
|
-
sleep 0.
|
|
492
|
+
sleep 0.5
|
|
489
493
|
end
|
|
490
494
|
end
|
|
491
495
|
|