-
Notifications
You must be signed in to change notification settings - Fork 49
Description
Originated in: #268 (comment)
The API, UDP, and HTTP tracker use a similar strategy to run the service instances. There are two levels of logic:
- The
ServiceController
- The
ServiceLauncher
ServiceController
The ServiceController
is responsible for the following:
- Storing the configuration needed to start the service (contained from the
config.toml
) file. - Starting and stopping the service
- Knowing the current state of the service:
running
orstopped
.
It does not store the configuration changes. If you stop the service, the next time you start it it will use the initial configuration when the ServiceController
was instantiated.
ServiceLauncher
The ServiceLauncher
is responsible for the following:
- Starting the service instance.
- Starting the service instance with a graceful shutdown. It can receive a shutdown signal.
Current implementations
Tracker API:
torrust_tracker::servers::apis::server::ApiServer<S>
(ServiceController
)torrust_tracker::servers::apis::server
andtorrust_tracker::servers::apis::server::start_tls
functions (ServiceLauncher
)
HTTP tracker:
torrust_tracker::servers::http::server::HttpServer
(ServiceController
)torrust_tracker::servers::http::v1::launcherstart
andtorrust_tracker::servers::http::v1::launcherstart_tls
functions (ServiceLauncher
)
UDP tracker:
torrust_tracker::servers::udp::server::UdpServer
(ServiceController
)torrust_tracker::servers::udp::server::Udp
(ServiceLauncher
)
Proposed changes
Some structs are only used for testing for the time being. We should move them to test modules until we needed in production code. For example, if we add a feature to check the state of a given service (we could show all the services and the ports they are using in an admin panel).
Structs only used for testing:
torrust_tracker::servers::apis::server::ApiServer<S>
(ServiceController
)torrust_tracker::servers::http::server::HttpServer
(ServiceController
)torrust_tracker::servers::udp::server::UdpServer
(ServiceController
)
Other dependencies are used only for testing too.
Future improvements
This is out of the scope of this issue, but maybe we could generalize a ServiceController
for services that need a socket port, which is, I think, what they have in common.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status