-
Notifications
You must be signed in to change notification settings - Fork 19
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
Horustctl #200
Horustctl #200
Conversation
6cdbbff
to
640f413
Compare
48a6270
to
df1041e
Compare
df1041e
to
31839f5
Compare
When can the pull request be merged? Apart from the feature, I would like to restart one of the services, not all of them. |
I have a suggestion to take refactoring such as splitting to smaller modules and making more cleaner out of this PR. Also plan on commands to support and make tool modular would be a nice idea:
As a critique of snipped you proposed, I'd like to have 2 status commands: one as in systemdctl, other is just for status without verbose output by default (which will be used by me in most of the cases). |
Motivation and Context
Because Horust is designed to be run inside containers, one could handle the lifecycle by for example restarting the docker container. In some cases, instead of restarting the whole container, one would want to restart a single service - or inspect its status etc. This PR will add support for horustctl, a command line that will allow to interact with horust.
Issue: #31
Description
I've reorganized the project to have three crates. Horust and horustctl are the two binaries. The interactions is accomplished using Unix Domain Sockets (UDS) and using Protobuf for the message definition. The Commands crate implements the required code and testing to use the uds.
On startup, Horust will create a new socket (and its folder if doesn't exists) in
/var/run/horust/horust-<pid>.sock
. This will allow using multiple horust instances on the same machine. The folder is configurable on both server and client.On client side, if no pid is specified horustctl will automatically search the folder and pick the only socket. If more than one socket is available, the command will fail.
I've decided to use protobuf3 for the definition of the messages, it turns out is quite verbose at least in rust, because all the messages are optional by default. If anyone wants to implement their own horustctl / client, they can reuse the protobuf.
I've considered adding tokio, but it's not worth bringing the runtime in just to handle this part of the program. There are also few interactions expected with this api, so I don't foresee performance issues.
The interactions are one shot: send a request, close the write socket, read the response. At least for now I don't have use case in mind that would require further interactions on the same connection.
I've also included the generated messages.rs module just to make browsing easier, I guess it's not a best practice to include generated files, but I don't see drawbacks with this.
Design
For now, the status works but It's still missing the update part. I'm thinking of merging the current changeset, and create a new pr to add the update part which seems a complicated change by itself.
For the status, now it just reports the status of the services. But I'm wondering if more info could be added.
Like:
Again, I'm thinking of merging this changeset and create a new pr.
How Has This Been Tested?
in one terminal:
in another terminal:
I've also added relevant integration tests.
Types of changes
Todo: