Skip to content
This repository has been archived by the owner on Dec 9, 2023. It is now read-only.

add the ability to stop a spawned thread #222

Open
nicbus opened this issue Nov 29, 2022 · 3 comments
Open

add the ability to stop a spawned thread #222

nicbus opened this issue Nov 29, 2022 · 3 comments
Labels
epic Large or meta-issues with multiple related issues and tasks feature New functionality
Milestone

Comments

@nicbus
Copy link
Contributor

nicbus commented Nov 29, 2022

rgb-node can be started as a thread but there is no way (I know of) to stop it

being able to gracefully stop the running thread is useful as it allows the spawning thread to bring operations to a halt in order to perform operations that are not possible while the service is running (e.g. moving files to a new location) or to re-launch the service with another configuration (e.g. different endpoints for other services)

note: the same idea also applies to other services (e.g. stored)

as discussed in a dev call, looks like a sensible way to implement this feature would be to add an API that allows the spawning thread to request a graceful stop, providing some identification token to prove it's the spawning thread (other threads should not be able to do the same)

@dr-orlovsky could you please implement this API?

@nicbus
Copy link
Contributor Author

nicbus commented Nov 29, 2022

@dr-orlovsky if you can provide your point of view and some guidance on how to implement this, I would be happy to help

@dr-orlovsky
Copy link
Member

Yeah, I did a research some time ago which ended up with the concept that there is no way how to stop the thread in Linux/POSIX :( Rust also does not provide an API for that.

The workaround would be to use dedicated messages to the thread with commands to stop, but this has to be done with a different thread managing architecture than the current one. I already work on it (it is a reactor-based architecture which you can find in https://github.com/Cyphernet-WG/rust-netservices) and plan to migrate nodes in a matter of few months. If this issue is not urgent it can wait that time since there is a dedicated "reactor shutdown channel" which gives the result you are asking for.

@dr-orlovsky dr-orlovsky added epic Large or meta-issues with multiple related issues and tasks feature New functionality labels Nov 29, 2022
@zoedberg zoedberg changed the title add the ability to stop a spwaned thread add the ability to stop a spawned thread Jan 16, 2023
@dr-orlovsky dr-orlovsky added this to the v0.10.0 milestone Jan 24, 2023
@dr-orlovsky
Copy link
Member

The plan is:

  1. Switch from RGB Node to RGB stdlib on mobile: https://github.com/orgs/RGB-WG/discussions/238
  2. Use new io-reactor instead of old microservices framework; which will get rid of many threads; brings control over the existing threads (with ability to stop) and many other optimizations: https://github.com/rust-amplify/io-reactor/releases/tag/v0.1.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
epic Large or meta-issues with multiple related issues and tasks feature New functionality
Projects
None yet
Development

No branches or pull requests

2 participants