Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add start and stop callbacks #1913

Merged
merged 10 commits into from
Jul 11, 2023
Prev Previous commit
Next Next commit
Do not error out when callbacks are not passed
  • Loading branch information
jevin committed Jun 22, 2023
commit ceb798ae625f4a8c088885360fe6ff7364ff0a2c
5 changes: 2 additions & 3 deletions lib/sinatra/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1568,7 +1568,7 @@ def quit!
set :running_server, nil
set :handler_name, nil

on_stop_callback.call
on_stop_callback.call if !on_stop_callback.nil?
jevin marked this conversation as resolved.
Show resolved Hide resolved
end

alias stop! quit!
Expand Down Expand Up @@ -1656,8 +1656,7 @@ def start_server(handler, server_settings, handler_name)
set :running_server, server
set :handler_name, handler_name
server.threaded = settings.threaded if server.respond_to? :threaded=

on_start_callback.call
on_start_callback.call if !on_start_callback.nil?
jevin marked this conversation as resolved.
Show resolved Hide resolved
yield server if block_given?
end
end
Expand Down