Open tadman opened 4 years ago
A reworked example that seems to function:
class ExampleController < Async::Container::Controller
def setup(container)
Async.logger.debug(self, "Container established.")
container.run(count: 1, restart: true) do |instance|
Async.logger.debug(self, "Child process started.")
Async do |task|
loop do
task.sleep(1)
end
end
instance.ready!
ensure
Async.logger.debug(self, "Child process exiting:", $!)
end
end
end
begin
controller = ExampleController.new
controller.run
ensure
Async.logger.debug(controller, "Parent process exiting:", $!)
end
Where the setup
method needs to be customized. Presumably new
could capture that block and use it within setup
?
I had it that way before but decided against it as a general pattern it's too magical and literally doesn't even really save more than a few lines of code.
Sorry, I don't understand my reply at all haha. I'm going to review this again.
The container example runs without doing anything:
Where the output is:
There's no mention of a "Child process" in there because the block is ignored.