Add support for not automatically starting applications
There are cases where we want a debug application (web server is a
reasonable example) which doesn't start up automatically, but can be
started on demand. Add an "autostart" to the application config entry
to signal this.
Change-Id: Id88ec8a164f42adb73902e2f0ba30c9d1ecea5c9
Signed-off-by: Austin Schuh <austin.schuh@bluerivertech.com>
diff --git a/aos/starter/starterd_lib.cc b/aos/starter/starterd_lib.cc
index 1c32be3..ff8bff9 100644
--- a/aos/starter/starterd_lib.cc
+++ b/aos/starter/starterd_lib.cc
@@ -23,6 +23,7 @@
args_(1),
user_(application->has_user() ? FindUid(application->user()->c_str())
: std::nullopt),
+ autostart_(application->autostart()),
event_loop_(event_loop),
start_timer_(event_loop_->AddTimer([this] {
status_ = aos::starter::State::RUNNING;
@@ -33,9 +34,7 @@
if (kill(pid_, SIGKILL) == 0) {
LOG(WARNING) << "Sent SIGKILL to " << name_ << " pid: " << pid_;
}
- }))
-
-{}
+ })) {}
void Application::DoStart() {
if (status_ != aos::starter::State::WAITING) {
@@ -481,7 +480,9 @@
#endif
for (auto &application : applications_) {
- application.second.Start();
+ if (application.second.autostart()) {
+ application.second.Start();
+ }
}
event_loop_.Run();