message: Gracefull shutdown to replay
diff: @@ -399,6 +399,7 @@ fn block_on_actors(
  &init_storage_data,
  chain_manager,
  block_applier,
  + block_applier_thread_watcher,
  shell_channel,
  log.clone(),
  );
  @@ -544,6 +545,7 @@ fn schedule_replay_blocks(
  init_storage_data: &StorageInitInfo,
  chain_manager: ChainManagerRef,
  block_applier: ChainFeederRef,
  + block_applier_thread_watcher: ThreadWatcher,
  shell_channel: ShellChannelRef,
  log: Logger,
  ) {
  @@ -580,13 +582,13 @@ fn schedule_replay_blocks(
  let percent = (index as f64 / nblocks as f64) * 100.0;
  if result.as_ref().is_err() {
  - replay_shutdown(shell_channel);
  + replay_shutdown(&log, shell_channel, block_applier_thread_watcher);
  panic!(
  "{:08} {:.5}% Block {} failed in {:?}. Result={:?}",
  index, percent, hash, time, result
  );
  } else if time > fail_above && index > 0 {
  - replay_shutdown(shell_channel);
  + replay_shutdown(&log, shell_channel, block_applier_thread_watcher);
  panic!(
  "{:08} {:.5}% Block {} processed in {:?} (more than {:?}). Result={:?}",
  index, percent, hash, time, fail_above, result
  @@ -611,10 +613,20 @@ fn schedule_replay_blocks(
  now.elapsed()
  );
  - replay_shutdown(shell_channel);
  + replay_shutdown(&log, shell_channel, block_applier_thread_watcher);
  +}
  +
  +fn replay_shutdown(
  + log: &Logger,
  + shell_channel: ShellChannelRef,
  + mut block_applier_thread_watcher: ThreadWatcher,
  +) {
  + if let Err(e) = block_applier_thread_watcher.stop() {
  + warn!(log, "Failed to stop thread watcher";
  + "thread_name" => block_applier_thread_watcher.thread_name(),
  + "reason" => format!("{}", e));
  }
  -fn replay_shutdown(shell_channel: ShellChannelRef) {
  shell_channel.tell(
  Publish {
  msg: ShuttingDown.into(),
  @@ -625,6 +637,13 @@ fn replay_shutdown(shell_channel: ShellChannelRef) {
  // give actors some time to shut down
  std::thread::sleep(Duration::from_secs(2));
  +
  + if let Some(thread) = block_applier_thread_watcher.thread() {
  + thread.thread().unpark();
  + if let Err(e) = thread.join() {
  + warn!(log, "Failed to wait for block applier thread"; "reason" => format!("{:?}", e));
  + }
  + }
  }
  fn collect_replayed_blocks(
  