2023-09-09 16:25:03 +00:00
|
|
|
use clap::Parser;
|
|
|
|
use lemmy_server::{init_logging, start_lemmy_server, CmdArgs};
|
2024-04-10 14:14:11 +00:00
|
|
|
use lemmy_utils::{error::LemmyResult, settings::SETTINGS};
|
2022-06-02 14:33:41 +00:00
|
|
|
|
2024-07-22 02:33:42 +00:00
|
|
|
pub extern crate rustls;
|
|
|
|
|
2023-06-26 08:24:11 +00:00
|
|
|
#[tokio::main]
|
2024-04-10 14:14:11 +00:00
|
|
|
pub async fn main() -> LemmyResult<()> {
|
2022-12-19 15:54:42 +00:00
|
|
|
init_logging(&SETTINGS.opentelemetry_url)?;
|
2023-09-09 16:25:03 +00:00
|
|
|
let args = CmdArgs::parse();
|
|
|
|
|
2024-07-22 02:33:42 +00:00
|
|
|
rustls::crypto::ring::default_provider()
|
|
|
|
.install_default()
|
|
|
|
.expect("Failed to install rustls crypto provider");
|
|
|
|
|
2023-01-20 17:46:49 +00:00
|
|
|
#[cfg(not(feature = "embed-pictrs"))]
|
2023-09-09 16:25:03 +00:00
|
|
|
start_lemmy_server(args).await?;
|
2023-01-20 17:46:49 +00:00
|
|
|
#[cfg(feature = "embed-pictrs")]
|
|
|
|
{
|
2023-06-20 11:07:18 +00:00
|
|
|
let pictrs_port = &SETTINGS
|
|
|
|
.pictrs_config()
|
|
|
|
.unwrap_or_default()
|
|
|
|
.url
|
|
|
|
.port()
|
|
|
|
.unwrap_or(8080);
|
|
|
|
let pictrs_address = ["127.0.0.1", &pictrs_port.to_string()].join(":");
|
2023-11-24 12:44:17 +00:00
|
|
|
let pictrs_config = pict_rs::ConfigSource::memory(serde_json::json!({
|
2023-01-20 17:46:49 +00:00
|
|
|
"server": {
|
2023-06-20 11:07:18 +00:00
|
|
|
"address": pictrs_address
|
2023-01-20 17:46:49 +00:00
|
|
|
},
|
|
|
|
"repo": {
|
|
|
|
"type": "sled",
|
|
|
|
"path": "./pictrs/sled-repo"
|
|
|
|
},
|
|
|
|
"store": {
|
|
|
|
"type": "filesystem",
|
|
|
|
"path": "./pictrs/files"
|
|
|
|
}
|
|
|
|
}))
|
|
|
|
.init::<&str>(None)
|
|
|
|
.expect("initialize pictrs config");
|
2023-11-24 12:44:17 +00:00
|
|
|
let (lemmy, pictrs) = tokio::join!(start_lemmy_server(args), pictrs_config.run_on_localset());
|
2023-01-20 17:46:49 +00:00
|
|
|
lemmy?;
|
|
|
|
pictrs.expect("run pictrs");
|
|
|
|
}
|
|
|
|
Ok(())
|
2019-03-21 01:22:31 +00:00
|
|
|
}
|