Skip to content

Commit 1b1ff07

Browse files
committed
Updated puma example.
1 parent 96aeb14 commit 1b1ff07

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

examples/puma/application.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,20 @@
88

99
class Application < Async::Container::Controller
1010
def setup(container)
11-
container.spawn(name: "Web") do |instance|
12-
instance.exec("bundle", "exec", "puma", "-C", "puma.rb", ready: false)
11+
container.spawn(name: "Web", restart: true) do |instance|
12+
pid = ::Process.spawn("puma")
13+
14+
instance.ready!
15+
16+
begin
17+
status = ::Process.wait2(pid)
18+
rescue Async::Container::Hangup
19+
Console.warn(self, "Restarting puma...")
20+
::Process.kill("USR1", pid)
21+
retry
22+
ensure
23+
::Process.kill("TERM", pid)
24+
end
1325
end
1426
end
1527
end

examples/puma/config.ru

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
run do |env|
2-
[200, {"content-type" => "text/plain"}, ["Hello World"]]
2+
[200, {"content-type" => "text/plain"}, ["Hello World #{Time.now}"]]
33
end

0 commit comments

Comments
 (0)