diff --git a/lib/puma/launcher.rb b/lib/puma/launcher.rb index 89e63896bf..1683460764 100644 --- a/lib/puma/launcher.rb +++ b/lib/puma/launcher.rb @@ -139,7 +139,6 @@ def halt # Begin async shutdown of the server gracefully def stop - @events.fire_on_stopped! @status = :stop @runner.stop end diff --git a/test/test_launcher.rb b/test/test_launcher.rb index ac790dce6b..3c9a57e958 100644 --- a/test/test_launcher.rb +++ b/test/test_launcher.rb @@ -174,6 +174,26 @@ def test_log_config_disabled refute_match(/Configuration:/, launcher.events.stdout.string) end + def test_fire_on_stopped + conf = Puma::Configuration.new do |c| + c.app -> {[200, {}, ['']]} + c.port UniquePort.call + end + + launcher = launcher(conf) + launcher.events.on_booted { + sleep 1.1 unless Puma.mri? + launcher.stop + } + launcher.events.on_stopped { puts 'on_stopped called' } + + out, = capture_io do + launcher.run + end + sleep 0.2 unless Puma.mri? + assert_equal 'on_stopped called', out.strip + end + private def events