diff options
Diffstat (limited to 'crates/server/src/main.rs')
-rw-r--r-- | crates/server/src/main.rs | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/crates/server/src/main.rs b/crates/server/src/main.rs deleted file mode 100644 index 968b3b87a..000000000 --- a/crates/server/src/main.rs +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
1 | #[macro_use] | ||
2 | extern crate log; | ||
3 | #[macro_use] | ||
4 | extern crate failure; | ||
5 | extern crate flexi_logger; | ||
6 | extern crate gen_lsp_server; | ||
7 | extern crate m; | ||
8 | |||
9 | use flexi_logger::{Logger, Duplicate}; | ||
10 | use gen_lsp_server::{run_server, stdio_transport}; | ||
11 | use m::Result; | ||
12 | |||
13 | fn main() -> Result<()> { | ||
14 | ::std::env::set_var("RUST_BACKTRACE", "short"); | ||
15 | Logger::with_env_or_str("error") | ||
16 | .duplicate_to_stderr(Duplicate::All) | ||
17 | .log_to_file() | ||
18 | .directory("log") | ||
19 | .start()?; | ||
20 | info!("lifecycle: server started"); | ||
21 | match ::std::panic::catch_unwind(|| main_inner()) { | ||
22 | Ok(res) => { | ||
23 | info!("lifecycle: terminating process with {:?}", res); | ||
24 | res | ||
25 | } | ||
26 | Err(_) => { | ||
27 | error!("server panicked"); | ||
28 | bail!("server panicked") | ||
29 | } | ||
30 | } | ||
31 | } | ||
32 | |||
33 | fn main_inner() -> Result<()> { | ||
34 | let (receiver, sender, threads) = stdio_transport(); | ||
35 | let cwd = ::std::env::current_dir()?; | ||
36 | run_server( | ||
37 | m::server_capabilities(), | ||
38 | |params, r, s| { | ||
39 | let root = params.root_uri | ||
40 | .and_then(|it| it.to_file_path().ok()) | ||
41 | .unwrap_or(cwd); | ||
42 | m::main_loop(false, root, r, s) | ||
43 | }, | ||
44 | receiver, | ||
45 | sender, | ||
46 | )?; | ||
47 | info!("shutting down IO..."); | ||
48 | threads.join()?; | ||
49 | info!("... IO is down"); | ||
50 | Ok(()) | ||
51 | } | ||
52 | |||