mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-12 13:18:47 +00:00
Cleanup log messages
This commit is contained in:
parent
7c67612b8a
commit
5896cd51de
2 changed files with 35 additions and 11 deletions
1
codeless/.gitignore
vendored
1
codeless/.gitignore
vendored
|
@ -4,3 +4,4 @@ artifacts.json
|
||||||
*.vsix
|
*.vsix
|
||||||
out/*
|
out/*
|
||||||
node_modules/*
|
node_modules/*
|
||||||
|
log/*
|
||||||
|
|
|
@ -41,10 +41,10 @@ fn main() -> Result<()> {
|
||||||
.log_to_file()
|
.log_to_file()
|
||||||
.directory("log")
|
.directory("log")
|
||||||
.start()?;
|
.start()?;
|
||||||
info!("starting server");
|
info!("lifecycle: server started");
|
||||||
match ::std::panic::catch_unwind(|| main_inner()) {
|
match ::std::panic::catch_unwind(|| main_inner()) {
|
||||||
Ok(res) => {
|
Ok(res) => {
|
||||||
info!("shutting down: {:?}", res);
|
info!("lifecycle: terminating process with {:?}", res);
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
|
@ -105,15 +105,31 @@ fn initialize(io: &mut Io) -> Result<()> {
|
||||||
type Thunk = Box<for<'a> FnBox<&'a mut Io, Result<()>>>;
|
type Thunk = Box<for<'a> FnBox<&'a mut Io, Result<()>>>;
|
||||||
|
|
||||||
fn initialized(io: &mut Io) -> Result<()> {
|
fn initialized(io: &mut Io) -> Result<()> {
|
||||||
let mut world = WorldState::new();
|
{
|
||||||
let mut pool = ThreadPool::new(4);
|
let mut world = WorldState::new();
|
||||||
let (sender, receiver) = bounded::<Thunk>(16);
|
let mut pool = ThreadPool::new(4);
|
||||||
let res = main_loop(io, &mut world, &mut pool, sender, receiver.clone());
|
let (sender, receiver) = bounded::<Thunk>(16);
|
||||||
info!("waiting for background jobs to finish...");
|
info!("lifecycle: handshake finished, server ready to serve requests");
|
||||||
receiver.for_each(drop);
|
let res = main_loop(io, &mut world, &mut pool, sender, receiver.clone());
|
||||||
pool.join();
|
info!("waiting for background jobs to finish...");
|
||||||
info!("...background jobs have finished");
|
receiver.for_each(drop);
|
||||||
res
|
pool.join();
|
||||||
|
info!("...background jobs have finished");
|
||||||
|
res
|
||||||
|
}?;
|
||||||
|
|
||||||
|
match io.recv()? {
|
||||||
|
RawMsg::Notification(n) => {
|
||||||
|
if n.method == "exit" {
|
||||||
|
info!("lifecycle: shutdown complete");
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
bail!("unexpected notification during shutdown: {:?}", n)
|
||||||
|
}
|
||||||
|
m => {
|
||||||
|
bail!("unexpected message during shutdown: {:?}", m)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main_loop(
|
fn main_loop(
|
||||||
|
@ -172,10 +188,17 @@ fn main_loop(
|
||||||
});
|
});
|
||||||
Ok(())
|
Ok(())
|
||||||
})?;
|
})?;
|
||||||
|
let mut shutdown = false;
|
||||||
dispatch::handle_request::<req::Shutdown, _>(&mut req, |(), resp| {
|
dispatch::handle_request::<req::Shutdown, _>(&mut req, |(), resp| {
|
||||||
resp.result(io, ())?;
|
resp.result(io, ())?;
|
||||||
|
shutdown = true;
|
||||||
Ok(())
|
Ok(())
|
||||||
})?;
|
})?;
|
||||||
|
if shutdown {
|
||||||
|
info!("lifecycle: initiating shutdown");
|
||||||
|
drop(sender);
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
if let Some(req) = req {
|
if let Some(req) = req {
|
||||||
error!("unknown method: {:?}", req);
|
error!("unknown method: {:?}", req);
|
||||||
dispatch::unknown_method(io, req)?;
|
dispatch::unknown_method(io, req)?;
|
||||||
|
|
Loading…
Reference in a new issue