Skip to content

Commit 349e724

Browse files
committed
Add readme.md to explain usage.
1 parent 9c5b417 commit 349e724

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

Diff for: examples/supervisor/readme.md

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Supervisor Example
2+
3+
This example demonstrates how to use the supervisor to detect memory leaks and respond to them.
4+
5+
## `falcon.rb` Configuration
6+
7+
The `falcon.rb` configuration file is used to configure the Falcon web server, along with the supervisor. We have a custom `MemoryMonitor` so we can override some of the behaviour when a memory leak is detected.
8+
9+
## Usage
10+
11+
First, start the Falcon web server with the supervisor:
12+
13+
```bash
14+
$ bundle exec falcon host falcon.rb
15+
```
16+
17+
Then, cause a server instance to leak memory:
18+
19+
```bash
20+
$ bake leak
21+
```
22+
23+
The supervisor will detect the memory leak and restart the server instance:
24+
25+
```
26+
50.17s error: Falcon::Configuration::Loader["falcon.rb"]::MemoryMonitor [oid=0x548] [ec=0x550] [pid=91808] [2025-03-01 12:43:04 +1300]
27+
| Memory leak detected in process:
28+
| {
29+
| "process_id": 91805,
30+
| "monitor": {
31+
| "process_id": 91805,
32+
| "current_size": 27279360,
33+
| "maximum_size": null,
34+
| "maximum_size_limit": 20971520,
35+
| "threshold_size": 10485760,
36+
| "increase_count": 0,
37+
| "increase_limit": 20
38+
| }
39+
| }
40+
50.27s info: Falcon::Configuration::Loader["falcon.rb"]::MemoryMonitor [oid=0x548] [ec=0x550] [pid=91808] [2025-03-01 12:43:04 +1300]
41+
| Memory dumped...
42+
| {
43+
| "response": {
44+
| "path": "memory-91805.json"
45+
| }
46+
| }
47+
50.27s info: Falcon::Configuration::Loader["falcon.rb"]::MemoryMonitor [oid=0x548] [ec=0x550] [pid=91808] [2025-03-01 12:43:04 +1300]
48+
| Killing process:
49+
| {
50+
| "process_id": 91805
51+
| }
52+
```

0 commit comments

Comments
 (0)