stable-cli-rails 0.6.5 → 0.6.6
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 +30 -54
- 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: 6c4c6a2df62447b539c1212d98c64f9cb33744454933fac73b9c86a763c951ac
|
|
4
|
+
data.tar.gz: 9a2f9cd59e224a67013a32351ec2bea6fda1097e01abd509594192b9648cbfa5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2fc9bcdc91837698b3127d656bf9837e358acb42704f71d6047d7bcbae0fdc3b14e442a7896eb34a9ca83f64cc3d3ea33295b46a478e1a62fd277f22c627d10c
|
|
7
|
+
data.tar.gz: 37a0545468ad7e1f2ca46e8e5039df4af1ecd71cee8b6d1eaaef9b6ad279969dd4bcc00abb050356113aae458229855c37ebccc8f81e1985aa09a1d9a79c8b10
|
data/lib/stable/cli.rb
CHANGED
|
@@ -73,31 +73,12 @@ module Stable
|
|
|
73
73
|
|
|
74
74
|
# --- Start Rails server ---
|
|
75
75
|
puts "Starting Rails server for #{name} on port #{port}..."
|
|
76
|
-
|
|
77
76
|
log_file = File.join(app_path, 'log', 'stable.log')
|
|
78
77
|
FileUtils.mkdir_p(File.dirname(log_file))
|
|
79
|
-
|
|
80
|
-
cmd = <<~CMD
|
|
81
|
-
bash -lc '
|
|
82
|
-
set -e
|
|
83
|
-
cd "#{app_path}"
|
|
84
|
-
|
|
85
|
-
export RAILS_ENV=development
|
|
86
|
-
export BUNDLE_GEMFILE="#{app_path}/Gemfile"
|
|
87
|
-
|
|
88
|
-
rvm #{ruby}@#{name} do bundle check || bundle install
|
|
89
|
-
rvm #{ruby}@#{name} do bundle exec rails db:prepare
|
|
90
|
-
|
|
91
|
-
exec rvm #{ruby}@#{name} do bundle exec rails s \
|
|
92
|
-
-p #{port} \
|
|
93
|
-
-b 127.0.0.1
|
|
94
|
-
'
|
|
95
|
-
CMD
|
|
96
|
-
|
|
97
|
-
pid = spawn(cmd, out: log_file, err: log_file)
|
|
78
|
+
pid = spawn("bash -lc 'rvm #{ruby}@#{name} do cd #{app_path} && bundle exec rails s -p #{port} >> #{log_file} 2>&1'")
|
|
98
79
|
Process.detach(pid)
|
|
99
80
|
|
|
100
|
-
wait_for_port(port
|
|
81
|
+
wait_for_port(port)
|
|
101
82
|
puts "✔ #{name} running at https://#{domain}"
|
|
102
83
|
end
|
|
103
84
|
|
|
@@ -177,42 +158,38 @@ module Stable
|
|
|
177
158
|
log_file = File.join(app[:path], 'log', 'stable.log')
|
|
178
159
|
FileUtils.mkdir_p(File.dirname(log_file))
|
|
179
160
|
|
|
180
|
-
|
|
181
|
-
if
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
161
|
+
ruby_exec =
|
|
162
|
+
if ruby
|
|
163
|
+
if rvm_available?
|
|
164
|
+
ensure_rvm_ruby!(ruby)
|
|
165
|
+
"rvm #{ruby}@#{name} do"
|
|
166
|
+
elsif rbenv_available?
|
|
167
|
+
ensure_rbenv_ruby!(ruby)
|
|
168
|
+
"RBENV_VERSION=#{ruby}"
|
|
169
|
+
else
|
|
170
|
+
puts 'No Ruby version manager found (rvm or rbenv)'
|
|
171
|
+
return
|
|
172
|
+
end
|
|
190
173
|
end
|
|
191
|
-
end
|
|
192
174
|
|
|
193
175
|
cmd = <<~CMD
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
cd "#{app_path}"
|
|
197
|
-
|
|
198
|
-
export RAILS_ENV=development
|
|
199
|
-
export BUNDLE_GEMFILE="#{app_path}/Gemfile"
|
|
200
|
-
|
|
201
|
-
rvm #{ruby}@#{name} do bundle check || bundle install
|
|
202
|
-
rvm #{ruby}@#{name} do bundle exec rails db:prepare
|
|
203
|
-
|
|
204
|
-
exec rvm #{ruby}@#{name} do bundle exec rails s \
|
|
205
|
-
-p #{port} \
|
|
206
|
-
-b 127.0.0.1
|
|
207
|
-
'
|
|
176
|
+
cd #{app[:path]} &&
|
|
177
|
+
#{ruby_exec} bundle exec rails s -p #{port}
|
|
208
178
|
CMD
|
|
209
179
|
|
|
210
|
-
pid = spawn(
|
|
180
|
+
pid = spawn(
|
|
181
|
+
'bash',
|
|
182
|
+
'-lc',
|
|
183
|
+
cmd,
|
|
184
|
+
out: log_file,
|
|
185
|
+
err: log_file
|
|
186
|
+
)
|
|
187
|
+
|
|
211
188
|
Process.detach(pid)
|
|
212
189
|
|
|
213
190
|
generate_cert(app[:domain])
|
|
214
191
|
update_caddyfile(app[:domain], port)
|
|
215
|
-
wait_for_port(port
|
|
192
|
+
wait_for_port(port)
|
|
216
193
|
caddy_reload
|
|
217
194
|
|
|
218
195
|
puts "#{name} started on https://#{app[:domain]}"
|
|
@@ -499,17 +476,16 @@ module Stable
|
|
|
499
476
|
end
|
|
500
477
|
end
|
|
501
478
|
|
|
502
|
-
def wait_for_port(port, timeout:
|
|
479
|
+
def wait_for_port(port, timeout: 5)
|
|
503
480
|
require 'socket'
|
|
504
|
-
|
|
505
|
-
|
|
481
|
+
start_time = Time.now
|
|
506
482
|
loop do
|
|
507
483
|
TCPSocket.new('127.0.0.1', port).close
|
|
508
|
-
|
|
484
|
+
break
|
|
509
485
|
rescue Errno::ECONNREFUSED
|
|
510
|
-
raise "
|
|
486
|
+
raise "Timeout waiting for port #{port}" if Time.now - start_time > timeout
|
|
511
487
|
|
|
512
|
-
sleep 0.
|
|
488
|
+
sleep 0.1
|
|
513
489
|
end
|
|
514
490
|
end
|
|
515
491
|
|