You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
2.4 KiB

#![cfg_attr(nightly, feature(int_error_matching))]
#![cfg_attr(nightly, feature(const_fn))]
#![cfg_attr(nightly, feature(maybe_uninit_ref))]
#![allow(dead_code)]
use tokio::{
select,
time::{
self,
Duration,
},
sync::{
mpsc,
},
task,
};
use lazy_static::lazy_static;
mod util;
use util::*;
mod log;
mod interval;
mod config;
mod live;
mod context;
mod job;
//test
async fn do_thing_every() -> Result<(mpsc::Sender<()>, task::JoinHandle<()>), Box<dyn std::error::Error>>
{
let mut interval = time::interval(Duration::from_secs(10));
let (tx, mut rx) = mpsc::channel(16);
let handle = tokio::spawn(async move {
println!("starting?");
loop {
let mut tick = interval.tick();
tokio::pin!(tick);
loop {
select!{
_ = &mut tick => {
// Do the things
println!("yes");
break;
}
command = rx.recv() => {
// We got interrupt, interpret `command` here.
// `continue` to continue waiting on this interval, break to go to next, return to stop
println!("no");
continue;
}
}
}
}
});
Ok((tx, handle))
}
fn print_stats()
{
lazy_static! {
static ref AUTHORS: String = env!("CARGO_PKG_AUTHORS").replace( ":", ", ");
};
status!("This is the lolicron daemon version {} by {}", env!("CARGO_PKG_VERSION"), &AUTHORS[..]);
status!("---");
status!("Compiled with:");
#[cfg(nightly)] status!(" +nightly");
#[cfg(debug_assertions)] status!(" +debug_assertions");
status!("features:");
#[cfg(feature="threaded")] status!(" +threaded");
status!("");
status!("GPl'd with <3");
status!("Please enjoy");
status!("---");
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
log::init(log::Level::Debug);
debug!("Logger initialised");
print_stats();
let oneesan = live::watch(".");
{
let mut recv = oneesan.hook("main.rs", live::filter::ALL).await;
while let Some(event) = recv.recv().await
{
important!("Got ev {:?}", event);
break;
}
}
oneesan.shutdown().await.expect("oneesan panic");
println!("{:?}", config::parse_global_single("example.rori").await.expect("Waaaaaah"));
//let (mut tx, h) = do_thing_every().await?;
// loop {
// time::delay_for(Duration::from_secs(6)).await;
// tx.send(()).await?;
// }
// h.await?;
Ok(())
}