2023-09-09 16:25:03 +00:00
|
|
|
use clap::Parser;
|
|
|
|
use lemmy_server::{init_logging, start_lemmy_server, CmdArgs};
|
2022-12-19 15:54:42 +00:00
|
|
|
use lemmy_utils::{error::LemmyError, settings::SETTINGS};
|
2022-06-02 14:33:41 +00:00
|
|
|
|
2023-06-26 08:24:11 +00:00
|
|
|
#[tokio::main]
|
2022-12-19 15:54:42 +00:00
|
|
|
pub async fn main() -> Result<(), LemmyError> {
|
|
|
|
init_logging(&SETTINGS.opentelemetry_url)?;
|
2023-09-09 16:25:03 +00:00
|
|
|
let args = CmdArgs::parse();
|
|
|
|
|
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-01-20 17:46:49 +00:00
|
|
|
pict_rs::ConfigSource::memory(serde_json::json!({
|
|
|
|
"server": {
|
2023-06-20 11:07:18 +00:00
|
|
|
"address": pictrs_address
|
2023-01-20 17:46:49 +00:00
|
|
|
},
|
|
|
|
"old_db": {
|
|
|
|
"path": "./pictrs/old"
|
|
|
|
},
|
|
|
|
"repo": {
|
|
|
|
"type": "sled",
|
|
|
|
"path": "./pictrs/sled-repo"
|
|
|
|
},
|
|
|
|
"store": {
|
|
|
|
"type": "filesystem",
|
|
|
|
"path": "./pictrs/files"
|
|
|
|
}
|
|
|
|
}))
|
|
|
|
.init::<&str>(None)
|
|
|
|
.expect("initialize pictrs config");
|
2023-09-09 16:25:03 +00:00
|
|
|
let (lemmy, pictrs) = tokio::join!(start_lemmy_server(args), pict_rs::run());
|
2023-01-20 17:46:49 +00:00
|
|
|
lemmy?;
|
|
|
|
pictrs.expect("run pictrs");
|
|
|
|
}
|
|
|
|
Ok(())
|
2019-03-21 01:22:31 +00:00
|
|
|
}
|