mirror of https://github.com/LemmyNet/lemmy.git
Merge branch 'teromene-config_dif_addr'
commit
d648eaaa5f
|
@ -42,18 +42,21 @@ use rand::distributions::Alphanumeric;
|
||||||
use rand::{thread_rng, Rng};
|
use rand::{thread_rng, Rng};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
use std::net::IpAddr;
|
||||||
|
|
||||||
pub struct Settings {
|
pub struct Settings {
|
||||||
db_url: String,
|
pub db_url: String,
|
||||||
hostname: String,
|
pub hostname: String,
|
||||||
jwt_secret: String,
|
pub bind: IpAddr,
|
||||||
rate_limit_message: i32,
|
pub port: u16,
|
||||||
rate_limit_message_per_second: i32,
|
pub jwt_secret: String,
|
||||||
rate_limit_post: i32,
|
pub rate_limit_message: i32,
|
||||||
rate_limit_post_per_second: i32,
|
pub rate_limit_message_per_second: i32,
|
||||||
rate_limit_register: i32,
|
pub rate_limit_post: i32,
|
||||||
rate_limit_register_per_second: i32,
|
pub rate_limit_post_per_second: i32,
|
||||||
email_config: Option<EmailConfig>,
|
pub rate_limit_register: i32,
|
||||||
|
pub rate_limit_register_per_second: i32,
|
||||||
|
pub email_config: Option<EmailConfig>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct EmailConfig {
|
pub struct EmailConfig {
|
||||||
|
@ -64,7 +67,7 @@ pub struct EmailConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Settings {
|
impl Settings {
|
||||||
fn get() -> Self {
|
pub fn get() -> Self {
|
||||||
dotenv().ok();
|
dotenv().ok();
|
||||||
|
|
||||||
let email_config =
|
let email_config =
|
||||||
|
@ -82,6 +85,14 @@ impl Settings {
|
||||||
Settings {
|
Settings {
|
||||||
db_url: env::var("DATABASE_URL").expect("DATABASE_URL must be set"),
|
db_url: env::var("DATABASE_URL").expect("DATABASE_URL must be set"),
|
||||||
hostname: env::var("HOSTNAME").unwrap_or("rrr".to_string()),
|
hostname: env::var("HOSTNAME").unwrap_or("rrr".to_string()),
|
||||||
|
bind: env::var("BIND")
|
||||||
|
.unwrap_or("0.0.0.0".to_string())
|
||||||
|
.parse()
|
||||||
|
.unwrap(),
|
||||||
|
port: env::var("PORT")
|
||||||
|
.unwrap_or("8536".to_string())
|
||||||
|
.parse()
|
||||||
|
.unwrap(),
|
||||||
jwt_secret: env::var("JWT_SECRET").unwrap_or("changeme".to_string()),
|
jwt_secret: env::var("JWT_SECRET").unwrap_or("changeme".to_string()),
|
||||||
rate_limit_message: env::var("RATE_LIMIT_MESSAGE")
|
rate_limit_message: env::var("RATE_LIMIT_MESSAGE")
|
||||||
.unwrap_or("30".to_string())
|
.unwrap_or("30".to_string())
|
||||||
|
|
|
@ -10,6 +10,7 @@ use lemmy_server::db::establish_connection;
|
||||||
use lemmy_server::feeds;
|
use lemmy_server::feeds;
|
||||||
use lemmy_server::nodeinfo;
|
use lemmy_server::nodeinfo;
|
||||||
use lemmy_server::websocket::server::*;
|
use lemmy_server::websocket::server::*;
|
||||||
|
use lemmy_server::Settings;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
|
@ -190,8 +191,10 @@ fn main() {
|
||||||
|
|
||||||
// Start chat server actor in separate thread
|
// Start chat server actor in separate thread
|
||||||
let server = ChatServer::default().start();
|
let server = ChatServer::default().start();
|
||||||
// Create Http server with websocket support
|
|
||||||
|
|
||||||
|
let settings = Settings::get();
|
||||||
|
|
||||||
|
// Create Http server with websocket support
|
||||||
HttpServer::new(move || {
|
HttpServer::new(move || {
|
||||||
App::new()
|
App::new()
|
||||||
.data(server.clone())
|
.data(server.clone())
|
||||||
|
@ -210,11 +213,11 @@ fn main() {
|
||||||
// static resources
|
// static resources
|
||||||
.service(actix_files::Files::new("/static", front_end_dir()))
|
.service(actix_files::Files::new("/static", front_end_dir()))
|
||||||
})
|
})
|
||||||
.bind("0.0.0.0:8536")
|
.bind((settings.bind, settings.port))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.start();
|
.start();
|
||||||
|
|
||||||
println!("Started http server: 0.0.0.0:8536");
|
println!("Started http server at {}:{}", settings.bind, settings.port);
|
||||||
let _ = sys.run();
|
let _ = sys.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue