diff --git a/examples/puma/application.rb b/examples/puma/application.rb index 44f28b7..6de687e 100755 --- a/examples/puma/application.rb +++ b/examples/puma/application.rb @@ -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 diff --git a/examples/puma/config.ru b/examples/puma/config.ru index 8440fb6..815d433 100644 --- a/examples/puma/config.ru +++ b/examples/puma/config.ru @@ -1,3 +1,3 @@ run do |env| - [200, {"content-type" => "text/plain"}, ["Hello World"]] + [200, {"content-type" => "text/plain"}, ["Hello World #{Time.now}"]] end