Skip to content

Commit

Permalink
[sm,launcher] Setup instance monitoring before instance is started
Browse files Browse the repository at this point in the history
Currently, the instance starts before instance monitoring,
which causes Aos Core to report increased system resource usage,
but no new instances are present in report.
This patch ensures that instance monitoring starts before
the instance itself.

Signed-off-by: Mykhailo Lohvynenko <[email protected]>
  • Loading branch information
mlohvynenko committed Jan 31, 2025
1 parent da033c6 commit d6f2278
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/sm/launcher/instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,24 @@ Error Instance::Start()
return err;
}

if (auto err = SetupMonitoring(); !err.IsNone()) {
return AOS_ERROR_WRAP(err);

Check warning on line 123 in src/sm/launcher/instance.cpp

View check run for this annotation

Codecov / codecov/patch

src/sm/launcher/instance.cpp#L123

Added line #L123 was not covered by tests
}

auto runStatus = mRunner.StartInstance(mInstanceID, mRuntimeDir, {});

auto onExit = DeferRelease(&runStatus, [this](runner::RunStatus* runStatus) {
if (!runStatus->mError.IsNone()) {
mResourceMonitor.StopInstanceMonitoring(mInstanceID);

Check warning on line 130 in src/sm/launcher/instance.cpp

View check run for this annotation

Codecov / codecov/patch

src/sm/launcher/instance.cpp#L130

Added line #L130 was not covered by tests
}
});

mRunState = runStatus.mState;

if (!runStatus.mError.IsNone()) {
return AOS_ERROR_WRAP(runStatus.mError);
}

if (auto err = SetupMonitoring(); !err.IsNone()) {
return err;
}

return ErrorEnum::eNone;
}

Expand Down

0 comments on commit d6f2278

Please sign in to comment.