hiiro 0.1.156 → 0.1.157
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/examples/services.sleepers.yml +41 -0
- data/lib/hiiro/service_manager.rb +57 -20
- data/lib/hiiro/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6a1dfe8868ee27e926e81edb4d93f9dd75bab129a493985a00505a267088e32c
|
|
4
|
+
data.tar.gz: c5f7a4fb1aea909d05ebb8e00a737bc28bf7524a19e4f52f7af518aba508d5f0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9dc4b695cbb678fa4ec76e940baba3356c67f6eeb551bcef4dd7f42de63c247fe42b9b98403a08ff7b0af406de0ce109d7bdbac9eda37dee71938b432566f114
|
|
7
|
+
data.tar.gz: f16b50413fd3c6e01b206bc385f08157fa504466470ad1dbb84dd9513c0253961f2c5a81f928fff0334241d40ac7fb1d64dd1a3e3e62da835e0ca4ea5b952cc8
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
s1:
|
|
3
|
+
base_dir: lib
|
|
4
|
+
host: localhost
|
|
5
|
+
port: '1111'
|
|
6
|
+
init:
|
|
7
|
+
- 'echo pwd: $PWD'
|
|
8
|
+
- pwd
|
|
9
|
+
- echo
|
|
10
|
+
- echo sleeper 1
|
|
11
|
+
start:
|
|
12
|
+
- sleep 1d
|
|
13
|
+
cleanup:
|
|
14
|
+
- ls -lA
|
|
15
|
+
env_files:
|
|
16
|
+
- env_file: ".env"
|
|
17
|
+
base_env: ''
|
|
18
|
+
env_vars:
|
|
19
|
+
hello: world
|
|
20
|
+
s2:
|
|
21
|
+
base_dir: lib
|
|
22
|
+
host: localhost
|
|
23
|
+
port: '2222'
|
|
24
|
+
init:
|
|
25
|
+
- 'echo pwd: $PWD'
|
|
26
|
+
- pwd
|
|
27
|
+
- echo
|
|
28
|
+
- echo sleeper 2
|
|
29
|
+
start:
|
|
30
|
+
- sleep 2d
|
|
31
|
+
cleanup:
|
|
32
|
+
- ls -lA
|
|
33
|
+
env_files:
|
|
34
|
+
- env_file: ".env"
|
|
35
|
+
base_env: ''
|
|
36
|
+
env_vars:
|
|
37
|
+
bye: world
|
|
38
|
+
ss:
|
|
39
|
+
services:
|
|
40
|
+
- name: s1
|
|
41
|
+
- name: s2
|
|
@@ -181,33 +181,26 @@ class Hiiro
|
|
|
181
181
|
return false
|
|
182
182
|
end
|
|
183
183
|
|
|
184
|
-
# Run init commands
|
|
185
|
-
if svc[:init]
|
|
186
|
-
base_dir = resolve_base_dir(svc[:base_dir])
|
|
187
|
-
svc[:init].each do |cmd|
|
|
188
|
-
system("cd #{base_dir} && #{cmd}")
|
|
189
|
-
end
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
# Prepare env files after init (e.g., init may install deps that generate .env templates)
|
|
193
|
-
unless skip_env
|
|
194
|
-
prepare_env(svc_name, variation_overrides: variation_overrides)
|
|
195
|
-
end
|
|
196
|
-
|
|
197
|
-
# Start the service
|
|
198
184
|
start_cmd = svc[:start]
|
|
199
185
|
unless start_cmd
|
|
200
186
|
puts "No start command configured for '#{svc_name}'"
|
|
201
187
|
return false
|
|
202
188
|
end
|
|
203
189
|
|
|
190
|
+
# Build separate init/env/start scripts + a launcher that runs them in order
|
|
191
|
+
init_cmds = Array(svc[:init] || [])
|
|
204
192
|
start_cmds = Array(start_cmd)
|
|
193
|
+
script = write_launcher_script(
|
|
194
|
+
svc_name,
|
|
195
|
+
init_cmds: init_cmds,
|
|
196
|
+
start_cmds: start_cmds,
|
|
197
|
+
env_prep: !skip_env,
|
|
198
|
+
variation_overrides: variation_overrides,
|
|
199
|
+
)
|
|
200
|
+
|
|
205
201
|
base_dir = resolve_base_dir(svc[:base_dir])
|
|
206
202
|
session = tmux_info[:session] || current_tmux_session
|
|
207
203
|
|
|
208
|
-
# Write start commands to an executable tempfile
|
|
209
|
-
script = write_start_script(svc_name, start_cmds)
|
|
210
|
-
|
|
211
204
|
if session && !skip_window_creation
|
|
212
205
|
# Create a new tmux window for this service
|
|
213
206
|
window_target = create_tmux_window(session, svc_name, base_dir)
|
|
@@ -754,19 +747,63 @@ class Hiiro
|
|
|
754
747
|
!system('tmux', 'has-session', '-t', pane_id, [:out, :err] => '/dev/null')
|
|
755
748
|
end
|
|
756
749
|
|
|
757
|
-
def
|
|
750
|
+
def scripts_dir
|
|
758
751
|
dir = File.join(STATE_DIR, 'scripts')
|
|
759
752
|
FileUtils.mkdir_p(dir)
|
|
760
|
-
|
|
753
|
+
dir
|
|
754
|
+
end
|
|
761
755
|
|
|
756
|
+
def write_shell_script(path, cmds)
|
|
762
757
|
lines = ["#!/usr/bin/env bash", "set -e"]
|
|
763
758
|
lines.concat(cmds)
|
|
764
|
-
|
|
765
759
|
File.write(path, lines.join("\n") + "\n")
|
|
766
760
|
File.chmod(0755, path)
|
|
767
761
|
path
|
|
768
762
|
end
|
|
769
763
|
|
|
764
|
+
def write_env_prep_script(svc_name, variation_overrides)
|
|
765
|
+
path = File.join(scripts_dir, "#{svc_name}-env.rb")
|
|
766
|
+
overrides_literal = variation_overrides.map { |k, v| "#{k.inspect} => #{v.inspect}" }.join(", ")
|
|
767
|
+
|
|
768
|
+
code = <<~RUBY
|
|
769
|
+
#!/usr/bin/env ruby
|
|
770
|
+
require 'hiiro'
|
|
771
|
+
sm = Hiiro::ServiceManager.new
|
|
772
|
+
sm.prepare_env(#{svc_name.inspect}, variation_overrides: { #{overrides_literal} })
|
|
773
|
+
RUBY
|
|
774
|
+
|
|
775
|
+
File.write(path, code)
|
|
776
|
+
File.chmod(0755, path)
|
|
777
|
+
path
|
|
778
|
+
end
|
|
779
|
+
|
|
780
|
+
def write_launcher_script(svc_name, init_cmds:, start_cmds:, env_prep: true, variation_overrides: {})
|
|
781
|
+
dir = scripts_dir
|
|
782
|
+
|
|
783
|
+
# Write init script (may be empty)
|
|
784
|
+
init_path = File.join(dir, "#{svc_name}-init.sh")
|
|
785
|
+
write_shell_script(init_path, init_cmds)
|
|
786
|
+
|
|
787
|
+
# Write start script
|
|
788
|
+
start_path = File.join(dir, "#{svc_name}-start.sh")
|
|
789
|
+
write_shell_script(start_path, start_cmds)
|
|
790
|
+
|
|
791
|
+
# Write env prep script
|
|
792
|
+
env_path = nil
|
|
793
|
+
if env_prep
|
|
794
|
+
env_path = write_env_prep_script(svc_name, variation_overrides)
|
|
795
|
+
end
|
|
796
|
+
|
|
797
|
+
# Write launcher that orchestrates: init -> env -> start
|
|
798
|
+
launcher_path = File.join(dir, "#{svc_name}.sh")
|
|
799
|
+
steps = []
|
|
800
|
+
steps << init_path unless init_cmds.empty?
|
|
801
|
+
steps << env_path if env_path
|
|
802
|
+
steps << "exec #{start_path}"
|
|
803
|
+
|
|
804
|
+
write_shell_script(launcher_path, steps)
|
|
805
|
+
end
|
|
806
|
+
|
|
770
807
|
def current_tmux_session
|
|
771
808
|
return nil unless ENV['TMUX']
|
|
772
809
|
`tmux display-message -p '#S'`.chomp
|
data/lib/hiiro/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hiiro
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.157
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Joshua Toyota
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-03-
|
|
11
|
+
date: 2026-03-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: pry
|
|
@@ -113,6 +113,7 @@ files:
|
|
|
113
113
|
- docs/h-session.md
|
|
114
114
|
- docs/h-window.md
|
|
115
115
|
- editboth
|
|
116
|
+
- examples/services.sleepers.yml
|
|
116
117
|
- examples/services.yml
|
|
117
118
|
- exe/h
|
|
118
119
|
- exe/hiiro
|