stable-cli-rails 0.6.2 → 0.6.4

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 +24 -5
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df1dff802e1adf63c1f0dd70227d09a33a32fb2678a06867a260208344cce9fe
4
- data.tar.gz: 1da4b5ca121d014c248cf3bad353cfc2176a03c85c8a5fb0ba23a15d437a7c65
3
+ metadata.gz: 113a2f424d8a2c9504aa4c05a3bce4cc06b3a0db2dec2006c9294a79e8bb1540
4
+ data.tar.gz: 7560db7955b8265db7e7ae14a4dcb7d67a0c4b738d96530010df23d44a66b1d9
5
5
  SHA512:
6
- metadata.gz: 96df4f8ef2eda56be3d7749436315bb1108969adc30c94daaf5d1c9fded4f83d027347dd228b587d7a821f63e27fdc36be85322523491bf5507af270e441253f
7
- data.tar.gz: 701bde4cfbfac53a7646cc3c480540608074918e8df00642961f683a81c29a380a264fe77015504fb92d4f53bd7b624f4c49fca0cba19bb84ac64af6c9c4e7e7
6
+ metadata.gz: 6c9d61943bb34d7750932ae4adc4ca6ab40c46338cc5c580287e85904219af314ea6a2a838c95548162f461f376404f22eba87f322a7a0d6807a5f54fbed6449
7
+ data.tar.gz: 201538f7c4268bbc719df1502d2fa1eb91a16e7b356874d37328a59b6c164947e8794a68149b5ca6c870d8e828a407c2b8beb6151060fdf031246490ed763e89
data/lib/stable/cli.rb CHANGED
@@ -71,14 +71,33 @@ module Stable
71
71
  ensure_caddy_running!
72
72
  caddy_reload
73
73
 
74
+ puts 'Preparing database...'
75
+
76
+ cmd = <<~CMD
77
+ bash -lc '
78
+ cd "#{app_path}" &&
79
+ rvm #{ruby}@#{name} do bundle exec rails db:prepare
80
+ '
81
+ CMD
82
+
83
+ system(cmd) or abort('Database preparation failed')
84
+
74
85
  # --- Start Rails server ---
75
86
  puts "Starting Rails server for #{name} on port #{port}..."
76
87
  log_file = File.join(app_path, 'log', 'stable.log')
77
88
  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'")
89
+
90
+ cmd = <<~CMD
91
+ bash -lc '
92
+ cd "#{app_path}" &&
93
+ rvm #{ruby}@#{name} do RAILS_ENV=development bundle exec rails s -p #{port} -b 127.0.0.1
94
+ '
95
+ CMD
96
+
97
+ pid = spawn(cmd, out: log_file, err: log_file)
79
98
  Process.detach(pid)
80
99
 
81
- wait_for_port(port, timeout: 45)
100
+ wait_for_port(port, timeout: 15)
82
101
  puts "✔ #{name} running at https://#{domain}"
83
102
  end
84
103
 
@@ -174,7 +193,7 @@ module Stable
174
193
 
175
194
  cmd = <<~CMD
176
195
  cd #{app[:path]} &&
177
- #{ruby_exec} bundle exec rails s -p #{port}
196
+ #{ruby_exec} RAILS_ENV=development bundle exec rails s -p #{port}
178
197
  CMD
179
198
 
180
199
  pid = spawn(
@@ -189,7 +208,7 @@ module Stable
189
208
 
190
209
  generate_cert(app[:domain])
191
210
  update_caddyfile(app[:domain], port)
192
- wait_for_port(port, timeout: 45)
211
+ wait_for_port(port, timeout: 15)
193
212
  caddy_reload
194
213
 
195
214
  puts "#{name} started on https://#{app[:domain]}"
@@ -476,7 +495,7 @@ module Stable
476
495
  end
477
496
  end
478
497
 
479
- def wait_for_port(port, timeout: 45)
498
+ def wait_for_port(port, timeout: 15)
480
499
  require 'socket'
481
500
  start = Time.now
482
501
 
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.2
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Simfukwe