{"action":"created","issue":{"url":"https://api.github.com/repos/passcod/cargo-watch/issues/25","labels_url":"https://api.github.com/repos/passcod/cargo-watch/issues/25/labels{/name}","comments_url":"https://api.github.com/repos/passcod/cargo-watch/issues/25/comments","events_url":"https://api.github.com/repos/passcod/cargo-watch/issues/25/events","html_url":"https://github.com/passcod/cargo-watch/issues/25","id":126306738,"number":25,"title":"workflow for server development","user":{"login":"mathroc","id":291531,"avatar_url":"https://avatars.githubusercontent.com/u/291531?v=3","gravatar_id":"","url":"https://api.github.com/users/mathroc","html_url":"https://github.com/mathroc","followers_url":"https://api.github.com/users/mathroc/followers","following_url":"https://api.github.com/users/mathroc/following{/other_user}","gists_url":"https://api.github.com/users/mathroc/gists{/gist_id}","starred_url":"https://api.github.com/users/mathroc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mathroc/subscriptions","organizations_url":"https://api.github.com/users/mathroc/orgs","repos_url":"https://api.github.com/users/mathroc/repos","events_url":"https://api.github.com/users/mathroc/events{/privacy}","received_events_url":"https://api.github.com/users/mathroc/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2016-01-12T23:56:05Z","updated_at":"2016-01-30T10:28:24Z","closed_at":null,"body":"when building a server (eg: a webserver that listen on port 3000), it could be useful to automatically kill the already running server (after successful re-compilation) before starting the new one. otherwise, the server cannot start again because the old one still listen to the same port.\r\n\r\nhere is a log of what is going, if the server is not killed:\r\n\r\n```\r\n# run rshello cargo watch run\r\n$ cargo run\r\n   Compiling hello_world v0.0.1 (file:///app)\r\n     Running `target/debug/hello_world`\r\n\r\n$ cargo run\r\n   Compiling hello_world v0.0.1 (file:///app)\r\n     Running `target/debug/hello_world`\r\nthread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: Io(Error { repr: Os { code: 98, message: \"Address already in use\" } })', ../src/libcore/result.rs:738\r\nProcess didn't exit successfully: `target/debug/hello_world` (exit code: 101)\r\n-> exit code: 101\r\n\r\n$ cargo run\r\n   Compiling hello_world v0.0.1 (file:///app)\r\n     Running `target/debug/hello_world`\r\nthread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: Io(Error { repr: Os { code: 98, message: \"Address already in use\" } })', ../src/libcore/result.rs:738\r\nProcess didn't exit successfully: `target/debug/hello_world` (exit code: 101)\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/passcod/cargo-watch/issues/comments/177138817","html_url":"https://github.com/passcod/cargo-watch/issues/25#issuecomment-177138817","issue_url":"https://api.github.com/repos/passcod/cargo-watch/issues/25","id":177138817,"user":{"login":"LukasKalbertodt","id":7419664,"avatar_url":"https://avatars.githubusercontent.com/u/7419664?v=3","gravatar_id":"","url":"https://api.github.com/users/LukasKalbertodt","html_url":"https://github.com/LukasKalbertodt","followers_url":"https://api.github.com/users/LukasKalbertodt/followers","following_url":"https://api.github.com/users/LukasKalbertodt/following{/other_user}","gists_url":"https://api.github.com/users/LukasKalbertodt/gists{/gist_id}","starred_url":"https://api.github.com/users/LukasKalbertodt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LukasKalbertodt/subscriptions","organizations_url":"https://api.github.com/users/LukasKalbertodt/orgs","repos_url":"https://api.github.com/users/LukasKalbertodt/repos","events_url":"https://api.github.com/users/LukasKalbertodt/events{/privacy}","received_events_url":"https://api.github.com/users/LukasKalbertodt/received_events","type":"User","site_admin":false},"created_at":"2016-01-30T10:28:24Z","updated_at":"2016-01-30T10:28:24Z","body":"Did some quick profiling:\r\n\r\n```rust\r\nfn main() {\r\n    let ns: u32 = std::env::args().nth(1).unwrap().parse().unwrap();\r\n    let dur = std::time::Duration::new(0, ns);\r\n\r\n    loop {\r\n        std::thread::sleep(dur);\r\n    }\r\n\r\n}\r\n```\r\n\r\nI don't even know if this is comparable with the `wait-timeout` crate, but it was easy. At 100_000 ns (= 100µs = 0.1 ms) I start noticing CPU usage (1% in my KSysGuard). But it's not getting worse with shorter durations. I suspect that this is due to the kernel's scheduling and that the process isn't actually woken up a lot faster than 100µs. \r\n\r\nIf we decide for (1), I would do some more profiling, of course."}}