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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/stable/cli.rb +30 -54
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 943a8bb18d00d40f3649f71f0de4ea5f27e3aed2fa115eee16044ab22607bf8f
4
- data.tar.gz: a0537cee5a9fe8bcbe77035b1b116a2274b66b26e131039397d5d15a3ba9a105
3
+ metadata.gz: 6c4c6a2df62447b539c1212d98c64f9cb33744454933fac73b9c86a763c951ac
4
+ data.tar.gz: 9a2f9cd59e224a67013a32351ec2bea6fda1097e01abd509594192b9648cbfa5
5
5
  SHA512:
6
- metadata.gz: d8de9e3bb95df90cdb1808c4bbab3116ff6930e33837a11cc123ed24fd45230a8d65114dfceb7bf242bb22f2e19dd426f7a88ea70e3433b6856a990642f1319f
7
- data.tar.gz: 7cd5cc00d03b662184586237fb8ff0126ca6381b7177c61458649b7b46a5a2be222bbb6311e31fa36564e9a5d34b2776bcdab2865ba3261d648c93ad3939d73b
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, timeout: 15)
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
- if ruby
181
- if rvm_available?
182
- ensure_rvm_ruby!(ruby)
183
- "rvm #{ruby}@#{name} do"
184
- elsif rbenv_available?
185
- ensure_rbenv_ruby!(ruby)
186
- "RBENV_VERSION=#{ruby}"
187
- else
188
- puts 'No Ruby version manager found (rvm or rbenv)'
189
- return
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
- bash -lc '
195
- set -e
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(cmd, out: log_file, err: log_file)
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, timeout: 15)
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: 15)
479
+ def wait_for_port(port, timeout: 5)
503
480
  require 'socket'
504
- start = Time.now
505
-
481
+ start_time = Time.now
506
482
  loop do
507
483
  TCPSocket.new('127.0.0.1', port).close
508
- return true
484
+ break
509
485
  rescue Errno::ECONNREFUSED
510
- raise "Rails failed to start on port #{port} within #{timeout}s" if Time.now - start > timeout
486
+ raise "Timeout waiting for port #{port}" if Time.now - start_time > timeout
511
487
 
512
- sleep 0.5
488
+ sleep 0.1
513
489
  end
514
490
  end
515
491
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stable-cli-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
4
+ version: 0.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Simfukwe