blob: d601c637ce850ecd77e554dfb530ce4f45e232bd [file] [log] [blame]
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "lifecycle.h"
#include <lib/fidl-async/cpp/bind.h>
#include <lib/syslog/cpp/macros.h>
namespace devmgr {
zx_status_t LifecycleServer::Create(
async_dispatcher_t* dispatcher, devmgr::FsManager* fs_manager,
fidl::ServerEnd<llcpp::fuchsia::process::lifecycle::Lifecycle> chan) {
zx_status_t status = fidl::BindSingleInFlightOnly(dispatcher, std::move(chan),
std::make_unique<LifecycleServer>(fs_manager));
if (status != ZX_OK) {
FX_LOGS(ERROR) << "failed to bind lifecycle service: " << zx_status_get_string(status);
return status;
}
return ZX_OK;
}
void LifecycleServer::Stop(StopCompleter::Sync& completer) {
FX_LOGS(INFO) << "received shutdown command over lifecycle interface";
fs_manager_->Shutdown([completer = completer.ToAsync()](zx_status_t status) mutable {
if (status != ZX_OK) {
FX_LOGS(ERROR) << "filesystem shutdown failed: " << zx_status_get_string(status);
} else {
// There are tests that watch for this message that will need updating if it changes.
FX_LOGS(INFO) << "fshost shutdown complete";
}
completer.Close(status);
});
}
} // namespace devmgr