88 lines
1.7 KiB
Rust
88 lines
1.7 KiB
Rust
extern crate rand;
|
|
extern crate uuid;
|
|
extern crate bcrypt;
|
|
extern crate chrono;
|
|
|
|
extern crate dotenv;
|
|
extern crate postgres;
|
|
extern crate r2d2;
|
|
extern crate r2d2_postgres;
|
|
extern crate fallible_iterator;
|
|
|
|
extern crate serde;
|
|
extern crate serde_cbor;
|
|
#[macro_use] extern crate serde_derive;
|
|
#[macro_use] extern crate failure;
|
|
|
|
extern crate fern;
|
|
#[macro_use] extern crate log;
|
|
|
|
extern crate stripe;
|
|
|
|
extern crate iron;
|
|
extern crate bodyparser;
|
|
extern crate persistent;
|
|
extern crate router;
|
|
extern crate cookie;
|
|
extern crate tungstenite;
|
|
|
|
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;
|
|
|
|
use std::thread::spawn;
|
|
use dotenv::dotenv;
|
|
|
|
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("actix_web", 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();
|
|
|
|
let pool = pg::create_pool();
|
|
|
|
let ws_pool = pool.clone();
|
|
let http_pool = pool.clone();
|
|
|
|
spawn(move || net::start(http_pool));
|
|
ws::start(ws_pool);
|
|
info!("server started");
|
|
}
|