blob: 9bc522cf8a8c7a0bff1c9fc99a3ebd8a7c96f537 [file] [log] [blame]
Alan Stokes9e2c5d52021-07-21 11:29:10 +01001/*
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
Victor Hsieh9ebf7ee2021-09-03 16:14:14 -070017//! A tool to start a standalone compsvc server that serves over RPC binder.
Alan Stokes9e2c5d52021-07-21 11:29:10 +010018
Alan Stokes183d7d32021-12-08 16:10:45 +000019mod artifact_signer;
Victor Hsieh51789de2021-08-06 16:50:49 -070020mod compilation;
Alan Stokes16fb8552022-02-10 15:07:27 +000021mod compos_key;
Alan Stokes9e2c5d52021-07-21 11:29:10 +010022mod compsvc;
Victor Hsieh9ed27182021-08-25 15:52:42 -070023mod fsverity;
Alan Stokes9e2c5d52021-07-21 11:29:10 +010024
David Brazdil671e6142022-11-16 11:47:27 +000025use anyhow::Result;
Alan Stokes17fd36a2021-09-06 17:22:37 +010026use compos_common::COMPOS_VSOCK_PORT;
Alan Stokesf30982b2022-11-18 11:50:32 +000027use log::{debug, error};
Alan Stokes7e8c9fc2022-02-02 18:02:41 +000028use std::panic;
Alan Stokes9e2c5d52021-07-21 11:29:10 +010029
Alan Stokese1b6e1c2021-10-01 12:44:49 +010030fn main() {
31 if let Err(e) = try_main() {
32 error!("failed with {:?}", e);
33 std::process::exit(1);
34 }
35}
36
37fn try_main() -> Result<()> {
Alan Stokes454069c2022-02-03 11:21:19 +000038 android_logger::init_once(
Jeff Vander Stoep57da1572024-01-31 10:52:16 +010039 android_logger::Config::default()
40 .with_tag("compsvc")
41 .with_max_level(log::LevelFilter::Debug),
Alan Stokes454069c2022-02-03 11:21:19 +000042 );
43 // Redirect panic messages to logcat.
44 panic::set_hook(Box::new(|panic_info| {
45 error!("{}", panic_info);
46 }));
Alan Stokes9e2c5d52021-07-21 11:29:10 +010047
Victor Hsieh9ebf7ee2021-09-03 16:14:14 -070048 debug!("compsvc is starting as a rpc service.");
Alan Stokes9fd57b02024-05-28 09:50:22 +010049 vm_payload::run_single_vsock_service(compsvc::new_binder()?, COMPOS_VSOCK_PORT)
Alan Stokese0945ad2022-11-24 13:29:57 +000050}