Skip to content

Commit 2c20fcf

Browse files
committed
lume: add service, improve test PID handling
1 parent e83342f commit 2c20fcf

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

Formula/l/lume.rb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,27 @@ def install
3030
end
3131
end
3232

33+
service do
34+
run [opt_bin/"lume", "serve"]
35+
keep_alive true
36+
working_dir var
37+
log_path var/"log/lume.log"
38+
error_log_path var/"log/lume.log"
39+
end
40+
3341
test do
3442
# Test ipsw command
3543
assert_match "Found latest IPSW URL", shell_output("#{bin}/lume ipsw")
3644

3745
# Test management HTTP server
38-
# Serves 404 Not found if no machines created
3946
port = free_port
40-
fork { exec bin/"lume", "serve", "--port", port.to_s }
47+
pid = spawn bin/"lume", "serve", "--port", port.to_s
4148
sleep 5
42-
assert_match %r{^HTTP/\d(.\d)? (200|404)}, shell_output("curl -si localhost:#{port}/lume").lines.first
49+
begin
50+
# Serves 404 Not found if no machines created
51+
assert_match %r{^HTTP/\d(.\d)? (200|404)}, shell_output("curl -si localhost:#{port}/lume").lines.first
52+
ensure
53+
Process.kill "SIGTERM", pid
54+
end
4355
end
4456
end

0 commit comments

Comments
 (0)