mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
update Readme with example of custom error handler
This commit is contained in:
parent
b8c087d967
commit
e2505dff98
1 changed files with 14 additions and 0 deletions
14
README.md
14
README.md
|
@ -121,6 +121,20 @@ When you use preload_app, your new code goes all in the master process, and is t
|
|||
|
||||
Note that preload_app can’t be used with phased restart, since phased restart kills and restarts workers one-by-one, and preload_app is all about copying the code of master into the workers.
|
||||
|
||||
### Error handler for low-level errors
|
||||
|
||||
If puma encounters an error outside of the context of your application, it will respond with a 500 and a simple
|
||||
textual error message (see `lowlevel_error` in [this file](https://github.com/puma/puma/blob/master/lib/puma/server.rb)).
|
||||
You can specify custom behavior for this scenario. For example, you can report the error to your third-party
|
||||
error-tracking service (in this example, [rollbar](http://rollbar.com)):
|
||||
|
||||
```ruby
|
||||
lowlevel_error_handler do |e|
|
||||
Rollbar.critical(e)
|
||||
[500, {}, ["An error has occured, and engineers have been informed. Please reload the page. If you continue to have problems, contact support@example.com\n"]]
|
||||
end
|
||||
```
|
||||
|
||||
### Binding TCP / Sockets
|
||||
|
||||
In contrast to many other server configs which require multiple flags, Puma simply uses one URI parameter with the `-b` (or `--bind`) flag:
|
||||
|
|
Loading…
Reference in a new issue