-
Notifications
You must be signed in to change notification settings - Fork 1
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
New method for unit start that reports whether the launch was successful #14
base: main
Are you sure you want to change the base?
Conversation
a9eae31
to
eddb6c6
Compare
Adds a `startAndWait` method in the TypeScript `Unit` class that starts a given unit/service and waits a certain amount of seconds between active state changes to determine and report whether the service start was successful or not. This is implemented in the Rust library as a `unit_start_and_wait` method of the `System` struct. Change-type: minor Signed-off-by: Zahari Petkov <[email protected]>
eddb6c6
to
9e06508
Compare
@@ -4,11 +4,11 @@ | |||
# - test the build of the project in a musl containerized environment | |||
# - provide an install to run integration tests | |||
# - generate a binary to be published with the package to be used by node-pre-gyp | |||
FROM alpine:3.20 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the version bump? This will update to Node 22 and abi v127 which I guess is the right thing as the supervisor is also on v22, but was just curious if you had a specific need for the new version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just did this to make the build pass, but this Dockerfile change is not resolved yet at all. Probably we need to install Rust manually with rustup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this builds with alpine:3.21, we can leave it at that as that version also matches what the supervisor is using
unit.start(mode) | ||
.await | ||
.with_context(|| format!("Failed to start unit {unit_path_str}"))?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only thing that I'm unsure about is that with this implementation there is some disconnection between the current action we are taking and the state of the unit. This call may fail because there is a queued job already for the unit, or perhaps this is queued and the result we get on the active state is the result from a previous operation. Perhaps we could also monitor the Job state until it switches from waiting
to running
?
I guess it depends on the case, but for something like the OS update it doesn't matter too much who started the update as long as you know that the process is running (even if the request came from a previous job) and have the exec status at the end.
let wait_duration = Duration::from_secs(wait_interval); | ||
|
||
// Either wait for next active state change event or stop if timeout is reached | ||
while let Ok(result) = time::timeout(wait_duration, stream.next()).await { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this always settle? Could stream output results forever causing us to keep waiting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will check this out in more detail to make sure the answer is yes.
The progress looks great. It would be good to add some tests as well |
Adds a
startAndWait
method in the TypeScriptUnit
class that starts a given unit/service and waits a certain amount of seconds between active state changes to determine and report whether the service start was successful or not.This is implemented in the Rust library as a
unit_start_and_wait
method of theSystem
struct.