-
Notifications
You must be signed in to change notification settings - Fork 41
Add support for HUP, USR1, USR2 signals #86
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
Conversation
Updated the dependency to use .product as instructed by SPM when trying to follow the instructions.
Updated target dependency example
Can one of the admins verify this patch? |
6 similar comments
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Motivation: Adding support for capturing HUP too in addition to USR1/USR2. Modifications: Added HUP signal, added descriptive strings for new signals. Result: HUP and USR signals available.
@swift-server-bot test this please |
I added HUP too. |
thanks @hassila the |
Sources/Lifecycle/Lifecycle.swift
Outdated
@@ -177,11 +177,13 @@ extension ServiceLifecycle { | |||
/// - signal: The signal to trap. | |||
/// - handler: closure to invoke when the signal is captured. | |||
/// - returns: a `DispatchSourceSignal` for the given trap. The source must be cancelled by the caller. | |||
public static func trap(signal sig: Signal, handler: @escaping (Signal) -> Void, on queue: DispatchQueue = .global()) -> DispatchSourceSignal { | |||
public static func trap(signal sig: Signal, handler: @escaping (Signal) -> Void, on queue: DispatchQueue = .global(), cancelAfterTrap: Bool = true) -> DispatchSourceSignal { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer we make cancelAfterTrap
default to true and change the internal call to set it to false, so the API is nicer to use from a user point of view
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely agree, +1. Only reason was reflex to not affect possible other users of API. Will fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed default in 8d379dc - missed mentioning it in commit message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one comment re. default and formatting issues
Motivation: Trying to adhere to code standards. Modifications: Removing tabs replacing with whitespace. Result: Adhering to soundness.sh, adding documentation.
@tomerd I tried to run soundness and failed: Assuming the return keys references CRLF issues (just a guess) but nothing obvious (file just edit on macOS and Linux with emacs/xcode). I have removed the tabs that were there previously though. Committed without tabs and added some documentation. |
Ok, I have tried to clean whitespace as much as possible, but I get this weird output from soundness.sh which is difficult to guess the purpose of:
|
@swift-server-bot test this please |
looks like formatting is still incorrect, run |
I tried swift format, but it did changes like:
will look at it bit more, but seemed a bit aggressive there :-) |
make sure you use |
I downloaded and built this one on Linux: https://github.com/nicklockwood/SwiftFormat - not the right one? |
jocke@swift511 ~/l/swift-service-lifecycle (hassila-usr-signals) [1]> swiftformat --version |
tool looks fine - I think ci uses 0.44.6 you can see the formatting issue in the log: https://ci.swiftserver.group/job/swift-service-lifecycle-soundness-prb/189/console |
Thanks, I couldn't find that log. Pushed fixes for those now. Seems the new version of swift formatter does a bit more, I will try to fetch 0.44.6 to try to get same output (until CI is updated). |
soundness.sh now passed for formatting at least, thanks for the patience answering questions. |
@swift-server-bot test this please |
Fixed in 265fb15. |
@swift-server-bot test this please |
(and installed exact version of swiftformat as used by CI for the future - 0.44.6 doesn't touch as aggressively and can and will now be used... thanks.) |
thanks @hassila |
Motivation:
Some servers want to support customised handling of signals except for simply shutting down.
Added support for USR1/USR2 signal traps for (#64) - extended trap() signature with one more optional argument to allow for signal handler to be run multiple times with usage like this: