Skip to content

Commit

Permalink
Updated puma example.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Dec 23, 2024
1 parent 96aeb14 commit 1b1ff07
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions examples/puma/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,20 @@

class Application < Async::Container::Controller
def setup(container)
container.spawn(name: "Web") do |instance|
instance.exec("bundle", "exec", "puma", "-C", "puma.rb", ready: false)
container.spawn(name: "Web", restart: true) do |instance|
pid = ::Process.spawn("puma")

instance.ready!

begin
status = ::Process.wait2(pid)
rescue Async::Container::Hangup
Console.warn(self, "Restarting puma...")
::Process.kill("USR1", pid)
retry
ensure
::Process.kill("TERM", pid)
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion examples/puma/config.ru
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
run do |env|
[200, {"content-type" => "text/plain"}, ["Hello World"]]
[200, {"content-type" => "text/plain"}, ["Hello World #{Time.now}"]]
end

0 comments on commit 1b1ff07

Please sign in to comment.