new rita has logs and id
-// #![feature(getpid)]
+#![feature(getpid)]
extern crate althea_kernel_interface;
extern crate babel_monitor;
extern crate traffic_watcher;
-// use std::process;
+use std::process;
extern crate docopt;
-// #[macro_use]
-// extern crate log;
+#[macro_use]
+extern crate log;
extern crate ip_network;
extern crate simple_logger;
@@ -21,15 +21,35 @@ use babel_monitor::Babel;
// use std::net::IpAddr;
// use ip_network::IpNetwork;
use std::net::SocketAddr;
-// use docopt::Docopt;
+use docopt::Docopt;
-// use std::fs::File;
-// use std::io::prelude::*;
+use std::fs::File;
+use std::io::prelude::*;
// use std::env;
use std::sync::mpsc;
use std::time::Duration;
+const USAGE: &'static str = "
+Usage: rita [--pid <pid file>]
+Options:
+ --pid Which file to write the PID to.
+";
+
fn main() {
+ simple_logger::init().unwrap();
+ trace!("Starting");
+
+ let args = Docopt::new(USAGE)
+ .and_then(|d| d.parse())
+ .unwrap_or_else(|e| e.exit());
+
+ if args.get_bool("--pid") {
+ let mut file = File::create(args.get_str("<pid file>")).unwrap();
+ file.write_all(format!("{}", process::id()).as_bytes())
+ .unwrap();
+ }
+
+
let (tx, rx) = mpsc::channel();
let mut ki = KernelInterface {};
@@ -49,10 +69,10 @@ fn main() {
// tx1.send(val).unwrap();
// thread::sleep(Duration::from_secs(1));
// }
- tx1.send(format!(
- "{:?}",
- traffic_watcher::watch(5, &mut ki, &mut babel)
- ))
+ // tx1.send(format!(
+ // "{:?}",
+ // traffic_watcher::watch(5, &mut ki, &mut babel)
+ // ))
});
thread::spawn(move || {
