phoenix-dataplane / phoenix

Phoenix dataplane system service
https://phoenix-dataplane.github.io
Apache License 2.0
51 stars 9 forks source link

[Enhanced] Add signal handler to release resources properly at exit #150

Closed XOR-op closed 2 years ago

XOR-op commented 2 years ago

Why are these changes needed?

Related issue number

Checks

Welcome for advice if I used something wrong with Rust.

crazyboycjr commented 2 years ago

Please run scripts/format.sh to pass the cargo format check.

crazyboycjr commented 2 years ago

LGTM. Thanks for your first (in fact second) PR!

libertyeagle commented 2 years ago

It seems using signal-hook crate (https://docs.rs/signal-hook/latest/signal_hook/flag/index.html) would make the code more clean. We should avoid using too many lazy_static in the code

crazyboycjr commented 2 years ago

It seems using signal-hook crate (https://docs.rs/signal-hook/latest/signal_hook/flag/index.html) would make the code more clean.

We should avoid using too many lazy_static in the code

Agreed about the lazy_static. I also noticed that there's a dozen crates doing this ctrl-c handling. In the end I just decide to reduce dependencies. Let's switch to 'signal-hook' when we need to handle more signals in the future.