Skip to content

Commit

Permalink
Merge pull request #143 from Burning1020/fix-task-server
Browse files Browse the repository at this point in the history
task: bugfix for ttrpc server closed
  • Loading branch information
abel-von committed Aug 2, 2024
2 parents 040871f + ab9484d commit 147412e
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions vmm/task/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ lazy_static! {
]);
}

async fn start_task_server() -> anyhow::Result<()> {
async fn initialize() -> anyhow::Result<()> {
early_init_call().await?;

let config = TaskConfig::new().await?;
Expand Down Expand Up @@ -172,16 +172,26 @@ async fn start_task_server() -> anyhow::Result<()> {

late_init_call().await?;

start_ttrpc_server().await?.start().await?;

Ok(())
}

#[tokio::main]
async fn main() {
// start task server
if let Err(e) = start_task_server().await {
error!("failed to start task server: {:?}", e);
if let Err(e) = initialize().await {
error!("failed to do init call: {:?}", e);
exit(-1);
}

// Keep server alive in main function
let mut server = match create_ttrpc_server().await {
Ok(s) => s,
Err(e) => {
error!("failed to create ttrpc server: {:?}", e);
exit(-1);
}
};
if let Err(e) = server.start().await {
error!("failed to start ttrpc server: {:?}", e);
exit(-1);
}

Expand Down Expand Up @@ -352,9 +362,9 @@ async fn mount_static_mounts(mounts: Vec<StaticMount>) -> Result<()> {
Ok(())
}

// start_ttrpc_server will create all the ttrpc service and register them to a server that
// create_ttrpc_server will create all the ttrpc service and register them to a server that
// bind to vsock 1024 port.
async fn start_ttrpc_server() -> anyhow::Result<Server> {
async fn create_ttrpc_server() -> anyhow::Result<Server> {
let task = create_task_service().await?;
let task_service = create_task(Arc::new(Box::new(task)));

Expand Down

0 comments on commit 147412e

Please sign in to comment.