feat(core): handling CTRL-C signal with graceful shutdown#2213
Conversation
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
e7d03ad to
ae8d70e
Compare
| ctx.stop().await.expect("Couldn't stop the KDF runtime."); | ||
| }; | ||
|
|
||
| // Please note we shouldn't use `MmCtx::spawner` to spawn this future, |
There was a problem hiding this comment.
nit: this is not really an issue here since the aborting code is in the last sync code block inside stop() so we won't yield back the execution to the runtime and thus won't die before we should.
We should be fine running the future inside the ctx spawner.
There was a problem hiding this comment.
I'm not sure if it's a good idea to spawn a future inside the future pool to clear the pool. Haven't checked that in detail but it may cause the future to deconstruct itself before it finishes. It's better to not touch that part and keep this PR as simple as possible.
There was a problem hiding this comment.
Note that, this isn't just about native threads, there is the JS runtime too.
There was a problem hiding this comment.
Agreed. It's not much of a difference and safer this way in case someone adds some awaited call after the abortion code.
We might as well then change...
| ctx.stop().await.expect("Couldn't stop the KDF runtime."); | ||
| }; | ||
|
|
||
| // Please note we shouldn't use `MmCtx::spawner` to spawn this future, |
There was a problem hiding this comment.
Agreed. It's not much of a difference and safer this way in case someone adds some awaited call after the abortion code.
We might as well then change...
mm2src/mm2_main/src/mm2.rs
Outdated
| /// It's important to spawn this task as soon as `Ctx` is in the correct state. | ||
| #[cfg(not(target_arch = "wasm32"))] | ||
| fn spawn_ctrl_c_handler(ctx: mm2_core::mm_ctx::MmArc) { | ||
| ctx.spawner().spawn(async move { |
There was a problem hiding this comment.
...this to not use the ctx spawner and call stop inside.
Let's use the global spawner here.
Signed-off-by: onur-ozkan <work@onurozkan.dev>
shamardy
left a comment
There was a problem hiding this comment.
Thanks for the PR! I have a few comments.
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
4dbf44e to
a3791bd
Compare
* dev: fix(orders): fix cancel order race condition using time-based cache (#2232) fix(legacy-swap): taker failed spend maker payment marked as failed (#2199) chore(adex-cli): deprecate adex-cli (#2234) feat(new-RPC): connection healthcheck implementation for peers (#2194) fix(proxy-signature): add message lifetime overflows (#2233) feat(CI): handle remote files in a safer way (#2217) chore(doc): update issue address in README (#2227) fix(merge): remove duplicated db_root function (#2229) feat(wallets): add `get_wallet_names` rpc (#2202) chore(tests): don't use `.wait()` and use `block_on` instead (#2220) fix(native-rpc): remove escaped response body (#2219) fix(clippy): fix coins mod clippy warnings in wasm (#2224) feat(core): handling CTRL-C signal with graceful shutdown (#2213) docs(README): fix typos (#2212) remove the non-sense arguments (#2216) fix(db): stop creating the all-zeroes dir on KDF start (#2218)
* dev: fix(orders): fix cancel order race condition using time-based cache (#2232) fix(legacy-swap): taker failed spend maker payment marked as failed (#2199) chore(adex-cli): deprecate adex-cli (#2234) feat(new-RPC): connection healthcheck implementation for peers (#2194) fix(proxy-signature): add message lifetime overflows (#2233) feat(CI): handle remote files in a safer way (#2217) chore(doc): update issue address in README (#2227) fix(merge): remove duplicated db_root function (#2229) feat(wallets): add `get_wallet_names` rpc (#2202) chore(tests): don't use `.wait()` and use `block_on` instead (#2220) fix(native-rpc): remove escaped response body (#2219) fix(clippy): fix coins mod clippy warnings in wasm (#2224) feat(core): handling CTRL-C signal with graceful shutdown (#2213) docs(README): fix typos (#2212) remove the non-sense arguments (#2216) fix(db): stop creating the all-zeroes dir on KDF start (#2218)
* dev: fix(cosmos): fix tx broadcasting error (#2238) chore(solana): remove solana implementation (#2239) chore(cli): remove leftover subcommands from help message (#2235) fix(orders): fix cancel order race condition using time-based cache (#2232) fix(legacy-swap): taker failed spend maker payment marked as failed (#2199) chore(adex-cli): deprecate adex-cli (#2234) feat(new-RPC): connection healthcheck implementation for peers (#2194) fix(proxy-signature): add message lifetime overflows (#2233) feat(CI): handle remote files in a safer way (#2217) chore(doc): update issue address in README (#2227) fix(merge): remove duplicated db_root function (#2229) feat(wallets): add `get_wallet_names` rpc (#2202) chore(tests): don't use `.wait()` and use `block_on` instead (#2220) fix(native-rpc): remove escaped response body (#2219) fix(clippy): fix coins mod clippy warnings in wasm (#2224) feat(core): handling CTRL-C signal with graceful shutdown (#2213) docs(README): fix typos (#2212) remove the non-sense arguments (#2216) fix(db): stop creating the all-zeroes dir on KDF start (#2218)
Closes #2145
To Test: cc @KomodoPlatform/qa
For testing on Windows and MacOS. Try CTRL-C on terminal for a running mm2 instance, it should work the same as using
stopRPC.