2019-05-03 01:34:21 +00:00
|
|
|
extern crate lemmy_server;
|
2019-07-17 11:11:01 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate diesel_migrations;
|
2019-03-21 01:22:31 +00:00
|
|
|
|
2019-07-19 03:05:17 +00:00
|
|
|
use actix_web::*;
|
2019-05-05 16:20:30 +00:00
|
|
|
use lemmy_server::db::establish_connection;
|
2019-12-31 15:44:30 +00:00
|
|
|
use lemmy_server::routes::{federation, feeds, index, nodeinfo, webfinger, websocket};
|
2019-12-15 16:40:55 +00:00
|
|
|
use lemmy_server::settings::Settings;
|
2019-04-06 05:29:20 +00:00
|
|
|
|
|
|
|
embed_migrations!();
|
2019-03-21 01:22:31 +00:00
|
|
|
|
|
|
|
fn main() {
|
2020-01-02 11:30:00 +00:00
|
|
|
env_logger::init();
|
2019-07-20 02:56:40 +00:00
|
|
|
let sys = actix::System::new("lemmy");
|
|
|
|
|
|
|
|
// Run the migrations from code
|
|
|
|
let conn = establish_connection();
|
|
|
|
embedded_migrations::run(&conn).unwrap();
|
|
|
|
|
2019-12-06 22:47:30 +00:00
|
|
|
let settings = Settings::get();
|
2019-12-06 19:36:56 +00:00
|
|
|
|
|
|
|
// Create Http server with websocket support
|
2019-07-20 02:56:40 +00:00
|
|
|
HttpServer::new(move || {
|
2019-12-31 12:55:33 +00:00
|
|
|
App::new()
|
|
|
|
.configure(federation::config)
|
|
|
|
.configure(feeds::config)
|
|
|
|
.configure(index::config)
|
|
|
|
.configure(nodeinfo::config)
|
|
|
|
.configure(webfinger::config)
|
|
|
|
.configure(websocket::config)
|
2019-12-28 21:06:37 +00:00
|
|
|
.service(actix_files::Files::new(
|
|
|
|
"/static",
|
|
|
|
settings.front_end_dir.to_owned(),
|
|
|
|
))
|
2020-01-01 22:47:00 +00:00
|
|
|
.service(actix_files::Files::new(
|
|
|
|
"/docs",
|
|
|
|
settings.front_end_dir.to_owned() + "/documentation",
|
|
|
|
))
|
2019-07-20 02:56:40 +00:00
|
|
|
})
|
2019-12-06 19:36:56 +00:00
|
|
|
.bind((settings.bind, settings.port))
|
2019-09-07 15:35:05 +00:00
|
|
|
.unwrap()
|
2020-01-10 22:41:08 +00:00
|
|
|
.run();
|
2019-07-17 11:11:01 +00:00
|
|
|
|
2019-12-06 19:36:56 +00:00
|
|
|
println!("Started http server at {}:{}", settings.bind, settings.port);
|
2019-07-20 02:56:40 +00:00
|
|
|
let _ = sys.run();
|
2019-03-21 01:22:31 +00:00
|
|
|
}
|