oops
This commit is contained in:
parent
4f3912a020
commit
f0787fa3a8
@ -27,86 +27,86 @@ extern crate cookie;
|
||||
extern crate tungstenite;
|
||||
extern crate crossbeam_channel;
|
||||
|
||||
// mod account;
|
||||
// mod construct;
|
||||
// mod effect;
|
||||
// mod game;
|
||||
// mod instance;
|
||||
// mod item;
|
||||
mod account;
|
||||
mod construct;
|
||||
mod effect;
|
||||
mod game;
|
||||
mod instance;
|
||||
mod item;
|
||||
mod img;
|
||||
// mod mob;
|
||||
// mod mtx;
|
||||
// mod names;
|
||||
// mod net;
|
||||
// mod payments;
|
||||
// mod pg;
|
||||
// mod player;
|
||||
// mod pubsub;
|
||||
// mod rpc;
|
||||
// mod skill;
|
||||
// mod spec;
|
||||
// mod util;
|
||||
// mod vbox;
|
||||
// mod warden;
|
||||
// mod ws;
|
||||
mod mob;
|
||||
mod mtx;
|
||||
mod names;
|
||||
mod net;
|
||||
mod payments;
|
||||
mod pg;
|
||||
mod player;
|
||||
mod pubsub;
|
||||
mod rpc;
|
||||
mod skill;
|
||||
mod spec;
|
||||
mod util;
|
||||
mod vbox;
|
||||
mod warden;
|
||||
mod ws;
|
||||
|
||||
// use std::thread::{sleep, spawn};
|
||||
// use std::time::{Duration};
|
||||
// use dotenv::dotenv;
|
||||
use std::thread::{sleep, spawn};
|
||||
use std::time::{Duration};
|
||||
use dotenv::dotenv;
|
||||
|
||||
// use pubsub::pg_listen;
|
||||
// use warden::warden;
|
||||
use pubsub::pg_listen;
|
||||
use warden::warden;
|
||||
|
||||
// fn setup_logger() -> Result<(), fern::InitError> {
|
||||
// fern::Dispatch::new()
|
||||
// .format(|out, message, record| {
|
||||
// out.finish(format_args!(
|
||||
// "{}[{}][{}] {}",
|
||||
// chrono::Local::now().format("[%Y-%m-%d][%H:%M:%S]"),
|
||||
// record.target(),
|
||||
// record.level(),
|
||||
// message
|
||||
// ))
|
||||
// })
|
||||
// .level_for("postgres", log::LevelFilter::Info)
|
||||
// .level_for("iron", log::LevelFilter::Info)
|
||||
// .level(log::LevelFilter::Info)
|
||||
// .chain(std::io::stdout())
|
||||
// .chain(fern::log_file("/var/log/mnml/mnml.log")?)
|
||||
// .apply()?;
|
||||
// Ok(())
|
||||
// }
|
||||
fn setup_logger() -> Result<(), fern::InitError> {
|
||||
fern::Dispatch::new()
|
||||
.format(|out, message, record| {
|
||||
out.finish(format_args!(
|
||||
"{}[{}][{}] {}",
|
||||
chrono::Local::now().format("[%Y-%m-%d][%H:%M:%S]"),
|
||||
record.target(),
|
||||
record.level(),
|
||||
message
|
||||
))
|
||||
})
|
||||
.level_for("postgres", log::LevelFilter::Info)
|
||||
.level_for("iron", log::LevelFilter::Info)
|
||||
.level(log::LevelFilter::Info)
|
||||
.chain(std::io::stdout())
|
||||
.chain(fern::log_file("/var/log/mnml/mnml.log")?)
|
||||
.apply()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// fn main() {
|
||||
// dotenv().ok();
|
||||
// setup_logger().unwrap();
|
||||
fn main() {
|
||||
dotenv().ok();
|
||||
setup_logger().unwrap();
|
||||
|
||||
// let pool = pg::create_pool();
|
||||
let pool = pg::create_pool();
|
||||
|
||||
// let ws_pool = pool.clone();
|
||||
// let http_pool = pool.clone();
|
||||
// let warden_pool = pool.clone();
|
||||
// let pubsub_pool = pool.clone();
|
||||
let ws_pool = pool.clone();
|
||||
let http_pool = pool.clone();
|
||||
let warden_pool = pool.clone();
|
||||
let pubsub_pool = pool.clone();
|
||||
|
||||
// spawn(move || {
|
||||
// loop {
|
||||
// let db_connection = warden_pool.get().expect("unable to get db connection");
|
||||
// if let Err(e) = warden(db_connection) {
|
||||
// info!("{:?}", e);
|
||||
// }
|
||||
// sleep(Duration::new(1, 0));
|
||||
// }
|
||||
// });
|
||||
spawn(move || {
|
||||
loop {
|
||||
let db_connection = warden_pool.get().expect("unable to get db connection");
|
||||
if let Err(e) = warden(db_connection) {
|
||||
info!("{:?}", e);
|
||||
}
|
||||
sleep(Duration::new(1, 0));
|
||||
}
|
||||
});
|
||||
|
||||
// spawn(move || loop {
|
||||
// let pubsub_conn = pubsub_pool.get().expect("could not get pubsub pg connection");
|
||||
// match pg_listen(pubsub_conn) {
|
||||
// Ok(_) => warn!("pg listen closed"),
|
||||
// Err(e) => warn!("pg_listen error {:?}", e),
|
||||
// }
|
||||
// });
|
||||
spawn(move || loop {
|
||||
let pubsub_conn = pubsub_pool.get().expect("could not get pubsub pg connection");
|
||||
match pg_listen(pubsub_conn) {
|
||||
Ok(_) => warn!("pg listen closed"),
|
||||
Err(e) => warn!("pg_listen error {:?}", e),
|
||||
}
|
||||
});
|
||||
|
||||
// spawn(move || net::start(http_pool));
|
||||
// ws::start(ws_pool);
|
||||
// info!("server started");
|
||||
// }
|
||||
spawn(move || net::start(http_pool));
|
||||
ws::start(ws_pool);
|
||||
info!("server started");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user