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

Define the on_stopped method in Puma::DSL #3411

Merged
merged 1 commit into from
Jun 15, 2024

Conversation

OuYangJinTing
Copy link
Contributor

@OuYangJinTing OuYangJinTing commented Jun 12, 2024

Description

This is how it is described in README.md
image

However, using on_stopped in fact leads to an exception because the on_stopped method is not defined in Puma::DSL.
image

Your checklist for this pull request

  • I have reviewed the guidelines for contributing to this repository.
  • I have added (or updated) appropriate tests if this PR fixes a bug or adds a feature.
  • My pull request is 100 lines added/removed or less so that it can be easily reviewed.
  • If this PR doesn't need tests (docs change), I added [ci skip] to the title of the PR.
  • If this closes any issues, I have added "Closes #issue" to the PR description or my commit messages.
  • I have updated the documentation accordingly.
  • All new and existing tests passed, including Rubocop.

PS: English is not my native language; please excuse typing errors.

Ref: #3379
Close #3380

Copy link
Member

@dentarg dentarg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add some test for this?

@dentarg dentarg added waiting-for-changes Waiting on changes from the requestor bug labels Jun 12, 2024
@OuYangJinTing
Copy link
Contributor Author

OuYangJinTing commented Jun 13, 2024

Can we add some test for this?

Please help me review it when you are free. Thank you.

@dentarg dentarg added waiting-for-review Waiting on review from anyone and removed waiting-for-changes Waiting on changes from the requestor labels Jun 15, 2024
Copy link
Member

@dentarg dentarg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How it looks:

~/src/puma defined_on_stopped
$ echo 'app { [200, {}, ["OK"]] }; on_booted { puts "Hello World!" }; on_stopped { puts "Goodbye from hook" }' | b e ruby -Ilib bin/puma --config /dev/stdin --port 0 --log-requests
Puma starting in single mode...
* Puma version: 6.4.2 (ruby 3.2.4-p170) ("The Eagle of Durango")
*  Min threads: 0
*  Max threads: 5
*  Environment: development
*          PID: 11825
* Listening on http://0.0.0.0:61897
Use Ctrl-C to stop
Hello World!
^CGoodbye from hook
- Gracefully stopping, waiting for requests to finish
=== puma shutdown: 2024-06-15 20:56:43 +0200 ===
- Goodbye!

~/src/puma defined_on_stopped
$ echo 'app { [200, {}, ["OK"]] }; on_booted { puts "Hello World!" }; on_stopped { puts "Goodbye from hook" }' | b e ruby -Ilib bin/puma --config /dev/stdin --port 0 --log-requests --workers 2
[12253] Puma starting in cluster mode...
[12253] * Puma version: 6.4.2 (ruby 3.2.4-p170) ("The Eagle of Durango")
[12253] *  Min threads: 0
[12253] *  Max threads: 5
[12253] *  Environment: development
[12253] *   Master PID: 12253
[12253] *      Workers: 2
[12253] *     Restarts: (✔) hot (✔) phased
[12253] * Listening on http://0.0.0.0:61915
[12253] Use Ctrl-C to stop
[12253] - Worker 0 (PID: 12255) booted in 0.0s, phase: 0
[12253] - Worker 1 (PID: 12256) booted in 0.0s, phase: 0
Hello World!
^C[12253] - Gracefully shutting down workers...
Goodbye from hook
[12253] === puma shutdown: 2024-06-15 20:57:07 +0200 ===
[12253] - Goodbye!

@dentarg dentarg merged commit 4172f18 into puma:master Jun 15, 2024
74 checks passed
@dentarg dentarg removed the waiting-for-review Waiting on review from anyone label Jun 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants