8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/browserctl/commands/status.rb', line 8
def self.run(client)
ping = client.ping
pages = client.list_pages[:pages] || []
page_info = pages.map do |name|
url_res = client.url(name)
{ name: name, url: url_res[:url] || url_res[:error] }
end
puts JSON.pretty_generate(
daemon: "online",
pid: ping[:pid],
protocol_version: ping[:protocol_version],
pages: page_info
)
rescue RuntimeError => e
raise unless e.message.include?("browserd is not running")
puts JSON.pretty_generate(daemon: "offline", error: e.message)
exit 1
end
|