1 /* 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 //! A tool to start a standalone compsvc server that serves over RPC binder. 18 19 mod artifact_signer; 20 mod compilation; 21 mod compos_key; 22 mod compsvc; 23 mod fsverity; 24 25 use anyhow::Result; 26 use compos_common::COMPOS_VSOCK_PORT; 27 use log::{debug, error}; 28 use std::panic; 29 main()30fn main() { 31 if let Err(e) = try_main() { 32 error!("failed with {:?}", e); 33 std::process::exit(1); 34 } 35 } 36 try_main() -> Result<()>37fn try_main() -> Result<()> { 38 android_logger::init_once( 39 android_logger::Config::default() 40 .with_tag("compsvc") 41 .with_max_level(log::LevelFilter::Debug), 42 ); 43 // Redirect panic messages to logcat. 44 panic::set_hook(Box::new(|panic_info| { 45 error!("{}", panic_info); 46 })); 47 48 debug!("compsvc is starting as a rpc service."); 49 vm_payload::run_single_vsock_service(compsvc::new_binder()?, COMPOS_VSOCK_PORT) 50 } 51