Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Add logging for worker spawn failures (#3827)
Browse files Browse the repository at this point in the history
  • Loading branch information
pepyakin committed Sep 10, 2021
1 parent a1399fb commit 7229ab8
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions node/core/pvf/src/worker_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,38 @@ pub async fn spawn_with_program_path(
with_transient_socket_path(debug_id, |socket_path| {
let socket_path = socket_path.to_owned();
async move {
let listener = UnixListener::bind(&socket_path).await.map_err(|_| SpawnErr::Bind)?;

let handle = WorkerHandle::spawn(program_path, extra_args, socket_path)
.map_err(|_| SpawnErr::ProcessSpawn)?;
let listener = UnixListener::bind(&socket_path).await.map_err(|err| {
tracing::warn!(
target: LOG_TARGET,
%debug_id,
"cannot bind unix socket: {:?}",
err,
);
SpawnErr::Bind
})?;

let handle =
WorkerHandle::spawn(program_path, extra_args, socket_path).map_err(|err| {
tracing::warn!(
target: LOG_TARGET,
%debug_id,
"cannot spawn a worker: {:?}",
err,
);
SpawnErr::ProcessSpawn
})?;

futures::select! {
accept_result = listener.accept().fuse() => {
let (stream, _) = accept_result.map_err(|_| SpawnErr::Accept)?;
let (stream, _) = accept_result.map_err(|err| {
tracing::warn!(
target: LOG_TARGET,
%debug_id,
"cannot accept a worker: {:?}",
err,
);
SpawnErr::Accept
})?;
Ok((IdleWorker { stream, pid: handle.id() }, handle))
}
_ = Delay::new(spawn_timeout).fuse() => {
Expand Down

0 comments on commit 7229ab8

Please sign in to comment.