2022-04-03 14:47:43 +03:00
|
|
|
#![recursion_limit = "128"]
|
|
|
|
// for diesel's infer_schema!
|
2017-11-15 17:06:18 +03:00
|
|
|
|
2018-10-27 12:42:09 +03:00
|
|
|
// Diesel causes many warnings of the following kind. I expect this to be
|
|
|
|
// fixed in a future release of Diesel. Currently used version of Diesel is
|
|
|
|
// 1.3.0.
|
|
|
|
#![allow(proc_macro_derive_resolution_fallback)]
|
|
|
|
|
2022-04-03 14:47:43 +03:00
|
|
|
#[cfg(test)]
|
|
|
|
#[macro_use]
|
|
|
|
extern crate matches;
|
|
|
|
#[cfg(test)]
|
|
|
|
#[macro_use]
|
|
|
|
extern crate indoc;
|
2017-11-15 18:27:28 +03:00
|
|
|
|
2022-04-03 14:47:43 +03:00
|
|
|
#[macro_use]
|
|
|
|
extern crate bart_derive;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate codegen;
|
|
|
|
#[macro_use]
|
|
|
|
#[allow(deprecated)]
|
|
|
|
extern crate diesel_infer_schema;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate diesel_migrations;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate diesel;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate hyper;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate lazy_static;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate maplit;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate serde_derive;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate serde_plain;
|
2017-11-15 17:06:18 +03:00
|
|
|
|
|
|
|
extern crate chrono;
|
|
|
|
extern crate diff;
|
|
|
|
extern crate futures;
|
2022-04-03 14:47:43 +03:00
|
|
|
extern crate futures_cpupool;
|
2017-11-15 17:06:18 +03:00
|
|
|
extern crate percent_encoding;
|
|
|
|
extern crate pulldown_cmark;
|
|
|
|
extern crate r2d2;
|
2022-04-03 14:47:43 +03:00
|
|
|
extern crate r2d2_diesel;
|
2018-10-05 12:56:53 +03:00
|
|
|
extern crate rand;
|
2018-06-17 22:25:35 +03:00
|
|
|
extern crate seahash;
|
2022-04-03 14:47:43 +03:00
|
|
|
extern crate serde;
|
2017-11-15 17:06:18 +03:00
|
|
|
extern crate serde_json;
|
|
|
|
extern crate serde_urlencoded;
|
|
|
|
extern crate slug;
|
|
|
|
extern crate titlecase;
|
|
|
|
|
|
|
|
use std::net::{IpAddr, SocketAddr};
|
|
|
|
|
|
|
|
mod assets;
|
2017-11-20 12:12:10 +03:00
|
|
|
mod build_config;
|
2017-11-15 17:06:18 +03:00
|
|
|
mod db;
|
2017-11-16 17:38:45 +03:00
|
|
|
mod merge;
|
2017-11-15 17:06:18 +03:00
|
|
|
mod mimes;
|
|
|
|
mod models;
|
|
|
|
mod rendering;
|
|
|
|
mod resources;
|
|
|
|
mod schema;
|
|
|
|
mod site;
|
|
|
|
mod state;
|
2018-09-18 08:56:58 +03:00
|
|
|
mod theme;
|
2017-11-15 17:06:18 +03:00
|
|
|
mod web;
|
|
|
|
mod wiki_lookup;
|
|
|
|
|
2022-04-03 14:47:43 +03:00
|
|
|
pub fn main(
|
|
|
|
db_file: String,
|
|
|
|
bind_host: IpAddr,
|
|
|
|
bind_port: u16,
|
|
|
|
trust_identity: bool,
|
|
|
|
) -> Result<(), Box<dyn std::error::Error>> {
|
2017-11-15 17:06:18 +03:00
|
|
|
let db_pool = db::create_pool(db_file)?;
|
|
|
|
let cpu_pool = futures_cpupool::CpuPool::new_num_cpus();
|
|
|
|
|
|
|
|
let state = state::State::new(db_pool, cpu_pool);
|
|
|
|
let lookup = wiki_lookup::WikiLookup::new(state, trust_identity);
|
|
|
|
|
2022-04-03 14:47:43 +03:00
|
|
|
let server = hyper::server::Http::new()
|
|
|
|
.bind(&SocketAddr::new(bind_host, bind_port), move || {
|
|
|
|
Ok(site::Site::new(lookup.clone(), trust_identity))
|
|
|
|
})?;
|
2017-11-15 17:06:18 +03:00
|
|
|
|
|
|
|
println!("Listening on http://{}", server.local_addr().unwrap());
|
|
|
|
|
|
|
|
server.run()?;
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|