| // Copyright 2021 The ChromiumOS Authors | |
| // Use of this source code is governed by a BSD-style license that can be | |
| // found in the LICENSE file. | |
| use anyhow::bail; | |
| use anyhow::Result; | |
| use libchromeos::panic_handler::install_memfd_handler; | |
| use libchromeos::syslog; | |
| use log::error; | |
| use log::info; | |
| use resourced::cpu_config; | |
| use resourced::dbus; | |
| use resourced::memory; | |
| use tokio::runtime::Builder; | |
| const IDENT: &str = "resourced"; | |
| fn main() -> Result<()> { | |
| install_memfd_handler(); | |
| // Initialize syslog. The default log level is info (debug! and trace! are ignored). | |
| // You can change the log level with log::set_max_level(). | |
| if let Err(e) = syslog::init(IDENT.to_string(), false /* log_to_stderr */) { | |
| bail!("Failed to initiailize syslog: {}", e); | |
| } | |
| info!("Starting resourced"); | |
| if let Err(err) = memory::init_memory_configs() { | |
| error!("Failed to initialize memory configs: {}", err); | |
| } | |
| if let Err(err) = cpu_config::init_cpu_config() { | |
| error!("Failed to initialize cpu configs: {}", err); | |
| } | |
| let rt = Builder::new_current_thread().enable_all().build()?; | |
| if let Err(err) = rt.block_on(dbus::service_main()) { | |
| error!("The D-Bus service main returns error: {:?}", err); | |
| } | |
| Ok(()) | |
| } |