stable-cli-rails 0.8.5 → 0.8.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 +10 -0
- data/lib/stable/commands/start_all.rb +12 -0
- data/lib/stable/commands/stop_all.rb +12 -0
- data/lib/stable/services/app_starter_all.rb +61 -0
- data/lib/stable/services/app_stopper_all.rb +39 -0
- data/lib/stable/services/rails/host_authorization.rb +2 -2
- data/lib/stable/services/tunneling/providers/stable.rb +0 -1
- metadata +5 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2655a1b03cdf3aea889733ae889cbabff743bb71a6646f57c259aa1f76f7dd3a
|
|
4
|
+
data.tar.gz: 280ebe18e77bf1e8c9b12f9c5470458a66748215ff4ceb6e8ec4ccb7d4384ee5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e61293aa6d7cd870638c2c67474567611911df140b2799298f1cafca39a67ce486c49f437e2c1b621b9b3865fbc762c3fd1d40f9ebbd8ff11b225a42b7628fc8
|
|
7
|
+
data.tar.gz: 98d2b634c897d5a223b71e5bb93d2c959600216224e2863159b98c9fa1fca592a32e1021ecde09a7739c51277f25c05dcf118af6211ea1b661fe62802b603de9
|
data/lib/stable/cli.rb
CHANGED
|
@@ -87,6 +87,11 @@ module Stable
|
|
|
87
87
|
Commands::Start.new(name).call
|
|
88
88
|
end
|
|
89
89
|
|
|
90
|
+
desc 'start-all', 'Start all registered Rails apps'
|
|
91
|
+
def start_all
|
|
92
|
+
Commands::StartAll.new.call
|
|
93
|
+
end
|
|
94
|
+
|
|
90
95
|
desc 'restart NAME', 'Restart a Rails app'
|
|
91
96
|
def restart(name)
|
|
92
97
|
Commands::Restart.new(name).call
|
|
@@ -97,6 +102,11 @@ module Stable
|
|
|
97
102
|
Commands::Stop.new(name).call
|
|
98
103
|
end
|
|
99
104
|
|
|
105
|
+
desc 'stop-all', 'Stop all running Rails apps'
|
|
106
|
+
def stop_all
|
|
107
|
+
Commands::StopAll.new.call
|
|
108
|
+
end
|
|
109
|
+
|
|
100
110
|
desc 'setup', 'Sets up Caddy and local trusted certificates'
|
|
101
111
|
def setup
|
|
102
112
|
Commands::Setup.new.call
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Stable
|
|
4
|
+
module Services
|
|
5
|
+
# Service for starting all Rails applications
|
|
6
|
+
class AppStarterAll
|
|
7
|
+
def initialize
|
|
8
|
+
@apps = AppRegistry.all
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def call
|
|
12
|
+
started_count = 0
|
|
13
|
+
|
|
14
|
+
@apps.each do |app|
|
|
15
|
+
if app_running?(app)
|
|
16
|
+
puts "#{app[:name]} is already running on https://#{app[:domain]} (port #{app[:port]})"
|
|
17
|
+
else
|
|
18
|
+
start_single_app(app)
|
|
19
|
+
started_count += 1
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
if started_count.zero?
|
|
24
|
+
puts 'All apps are already running'
|
|
25
|
+
else
|
|
26
|
+
puts "Started #{started_count} app(s)"
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
def app_running?(app)
|
|
33
|
+
return false unless app
|
|
34
|
+
|
|
35
|
+
# First check if we have PID info and if process is alive
|
|
36
|
+
return ProcessManager.pid_alive?(app[:pid]) if app[:pid] && app[:started_at]
|
|
37
|
+
|
|
38
|
+
# Fallback to port checking if no PID info available
|
|
39
|
+
return false unless app[:port]
|
|
40
|
+
|
|
41
|
+
Stable::Utils::Platform.port_in_use?(app[:port])
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def start_single_app(app)
|
|
45
|
+
app_starter = Services::AppStarter.new(app[:name])
|
|
46
|
+
# Suppress individual output by redirecting puts temporarily
|
|
47
|
+
original_stdout = $stdout
|
|
48
|
+
$stdout = StringIO.new
|
|
49
|
+
|
|
50
|
+
begin
|
|
51
|
+
app_starter.call
|
|
52
|
+
ensure
|
|
53
|
+
$stdout = original_stdout
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Provide our own simplified output
|
|
57
|
+
puts "✔ #{app[:name]} started on https://#{app[:domain]}"
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Stable
|
|
4
|
+
module Services
|
|
5
|
+
# Service for stopping all Rails applications
|
|
6
|
+
class AppStopperAll
|
|
7
|
+
def initialize
|
|
8
|
+
@apps = AppRegistry.all
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def call
|
|
12
|
+
stopped_count = 0
|
|
13
|
+
|
|
14
|
+
@apps.each do |app|
|
|
15
|
+
next unless app_running?(app)
|
|
16
|
+
|
|
17
|
+
ProcessManager.stop(app)
|
|
18
|
+
AppRegistry.mark_stopped(app[:name])
|
|
19
|
+
puts "✔ #{app[:name]} stopped"
|
|
20
|
+
stopped_count += 1
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
if stopped_count.zero?
|
|
24
|
+
puts 'No running apps found'
|
|
25
|
+
else
|
|
26
|
+
puts "Stopped #{stopped_count} app(s)"
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
def app_running?(app)
|
|
33
|
+
return false unless app[:port]
|
|
34
|
+
|
|
35
|
+
Stable::Utils::Platform.find_pids_by_port(app[:port]).any?
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -55,8 +55,8 @@ module Stable
|
|
|
55
55
|
|
|
56
56
|
content = File.read(env_rb)
|
|
57
57
|
content.include?('config.load_defaults 6') ||
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
content.include?('config.load_defaults 7') ||
|
|
59
|
+
content.include?('config.load_defaults 8')
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
62
|
end
|
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.8.
|
|
4
|
+
version: 0.8.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Danny Simfukwe
|
|
@@ -61,7 +61,9 @@ files:
|
|
|
61
61
|
- lib/stable/commands/setup.rb
|
|
62
62
|
- lib/stable/commands/share.rb
|
|
63
63
|
- lib/stable/commands/start.rb
|
|
64
|
+
- lib/stable/commands/start_all.rb
|
|
64
65
|
- lib/stable/commands/stop.rb
|
|
66
|
+
- lib/stable/commands/stop_all.rb
|
|
65
67
|
- lib/stable/commands/unshare.rb
|
|
66
68
|
- lib/stable/commands/upgrade_ruby.rb
|
|
67
69
|
- lib/stable/commands/workdir.rb
|
|
@@ -77,7 +79,9 @@ files:
|
|
|
77
79
|
- lib/stable/services/app_remover.rb
|
|
78
80
|
- lib/stable/services/app_restarter.rb
|
|
79
81
|
- lib/stable/services/app_starter.rb
|
|
82
|
+
- lib/stable/services/app_starter_all.rb
|
|
80
83
|
- lib/stable/services/app_stopper.rb
|
|
84
|
+
- lib/stable/services/app_stopper_all.rb
|
|
81
85
|
- lib/stable/services/app_upgrader.rb
|
|
82
86
|
- lib/stable/services/caddy_manager.rb
|
|
83
87
|
- lib/stable/services/cli/qrcode.rb
|