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
Add a description for lifecycle events
  • Loading branch information
jevin committed Jun 22, 2023
commit 3cf129b6749e120ce32bd35062c92dffa27ebf59
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2226,6 +2226,22 @@ set :protection, :session => true

## Lifecycle Events

There are 2 lifecycle events currently exposed by Sinatra. One when the server starts and one when it stops.

They can be used like this:

```
on_start do
puts "===== Booting up ====="
end

on_stop do
puts "===== Shutting down ====="
end
```

Note that these callbacks only work when using Sinatra to start the web server.

## Environments

There are three predefined `environments`: `"development"`,
Expand Down