parent
007e9b7aab
commit
ae9f82b452
8 changed files with 12 additions and 20 deletions
|
@ -15,7 +15,7 @@ use lemmy_db_views::structs::{CustomEmojiView, LocalUserView, SiteView};
|
||||||
use lemmy_db_views_actor::structs::PersonView;
|
use lemmy_db_views_actor::structs::PersonView;
|
||||||
use lemmy_utils::{
|
use lemmy_utils::{
|
||||||
error::{LemmyError, LemmyErrorType},
|
error::{LemmyError, LemmyErrorType},
|
||||||
version,
|
VERSION,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[tracing::instrument(skip(context))]
|
#[tracing::instrument(skip(context))]
|
||||||
|
@ -68,7 +68,7 @@ pub async fn leave_admin(
|
||||||
Ok(Json(GetSiteResponse {
|
Ok(Json(GetSiteResponse {
|
||||||
site_view,
|
site_view,
|
||||||
admins,
|
admins,
|
||||||
version: version::VERSION.to_string(),
|
version: VERSION.to_string(),
|
||||||
my_user: None,
|
my_user: None,
|
||||||
all_languages,
|
all_languages,
|
||||||
discussion_languages,
|
discussion_languages,
|
||||||
|
|
|
@ -19,8 +19,8 @@ use lemmy_utils::{
|
||||||
error::{LemmyError, LemmyErrorType},
|
error::{LemmyError, LemmyErrorType},
|
||||||
settings::structs::{PictrsImageMode, Settings},
|
settings::structs::{PictrsImageMode, Settings},
|
||||||
spawn_try_task,
|
spawn_try_task,
|
||||||
version::VERSION,
|
|
||||||
REQWEST_TIMEOUT,
|
REQWEST_TIMEOUT,
|
||||||
|
VERSION,
|
||||||
};
|
};
|
||||||
use mime::Mime;
|
use mime::Mime;
|
||||||
use reqwest::{header::CONTENT_TYPE, Client, ClientBuilder};
|
use reqwest::{header::CONTENT_TYPE, Client, ClientBuilder};
|
||||||
|
@ -32,11 +32,7 @@ use urlencoding::encode;
|
||||||
use webpage::HTML;
|
use webpage::HTML;
|
||||||
|
|
||||||
pub fn client_builder(settings: &Settings) -> ClientBuilder {
|
pub fn client_builder(settings: &Settings) -> ClientBuilder {
|
||||||
let user_agent = format!(
|
let user_agent = format!("Lemmy/{VERSION}; +{}", settings.get_protocol_and_hostname());
|
||||||
"Lemmy/{}; +{}",
|
|
||||||
VERSION,
|
|
||||||
settings.get_protocol_and_hostname()
|
|
||||||
);
|
|
||||||
|
|
||||||
Client::builder()
|
Client::builder()
|
||||||
.user_agent(user_agent.clone())
|
.user_agent(user_agent.clone())
|
||||||
|
|
|
@ -20,7 +20,7 @@ use lemmy_db_views_actor::structs::{
|
||||||
};
|
};
|
||||||
use lemmy_utils::{
|
use lemmy_utils::{
|
||||||
error::{LemmyError, LemmyErrorExt, LemmyErrorType},
|
error::{LemmyError, LemmyErrorExt, LemmyErrorType},
|
||||||
version,
|
VERSION,
|
||||||
};
|
};
|
||||||
use moka::future::Cache;
|
use moka::future::Cache;
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
|
@ -52,7 +52,7 @@ pub async fn get_site(
|
||||||
Ok(GetSiteResponse {
|
Ok(GetSiteResponse {
|
||||||
site_view,
|
site_view,
|
||||||
admins,
|
admins,
|
||||||
version: version::VERSION.to_string(),
|
version: VERSION.to_string(),
|
||||||
my_user: None,
|
my_user: None,
|
||||||
all_languages,
|
all_languages,
|
||||||
discussion_languages,
|
discussion_languages,
|
||||||
|
|
|
@ -6,7 +6,7 @@ use lemmy_db_views::structs::SiteView;
|
||||||
use lemmy_utils::{
|
use lemmy_utils::{
|
||||||
cache_header::{cache_1hour, cache_3days},
|
cache_header::{cache_1hour, cache_3days},
|
||||||
error::LemmyError,
|
error::LemmyError,
|
||||||
version,
|
VERSION,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
@ -56,7 +56,7 @@ async fn node_info(context: web::Data<LemmyContext>) -> Result<HttpResponse, Err
|
||||||
version: Some("2.0".to_string()),
|
version: Some("2.0".to_string()),
|
||||||
software: Some(NodeInfoSoftware {
|
software: Some(NodeInfoSoftware {
|
||||||
name: Some("lemmy".to_string()),
|
name: Some("lemmy".to_string()),
|
||||||
version: Some(version::VERSION.to_string()),
|
version: Some(VERSION.to_string()),
|
||||||
}),
|
}),
|
||||||
protocols,
|
protocols,
|
||||||
usage: Some(NodeInfoUsage {
|
usage: Some(NodeInfoUsage {
|
||||||
|
|
|
@ -10,7 +10,6 @@ cfg_if! {
|
||||||
pub mod response;
|
pub mod response;
|
||||||
pub mod settings;
|
pub mod settings;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
pub mod version;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +19,8 @@ use std::time::Duration;
|
||||||
|
|
||||||
pub type ConnectionId = usize;
|
pub type ConnectionId = usize;
|
||||||
|
|
||||||
|
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
|
|
||||||
pub const REQWEST_TIMEOUT: Duration = Duration::from_secs(10);
|
pub const REQWEST_TIMEOUT: Duration = Duration::from_secs(10);
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
pub const VERSION: &str = "unknown version";
|
|
|
@ -28,7 +28,6 @@ COPY . ./
|
||||||
# Debug build
|
# Debug build
|
||||||
RUN --mount=type=cache,target=/lemmy/target set -ex; \
|
RUN --mount=type=cache,target=/lemmy/target set -ex; \
|
||||||
if [ "${RUST_RELEASE_MODE}" = "debug" ]; then \
|
if [ "${RUST_RELEASE_MODE}" = "debug" ]; then \
|
||||||
echo "pub const VERSION: &str = \"$(git describe --tag)\";" > crates/utils/src/version.rs; \
|
|
||||||
cargo build --features "${CARGO_BUILD_FEATURES}"; \
|
cargo build --features "${CARGO_BUILD_FEATURES}"; \
|
||||||
mv target/"${RUST_RELEASE_MODE}"/lemmy_server ./lemmy_server; \
|
mv target/"${RUST_RELEASE_MODE}"/lemmy_server ./lemmy_server; \
|
||||||
fi
|
fi
|
||||||
|
@ -36,7 +35,6 @@ RUN --mount=type=cache,target=/lemmy/target set -ex; \
|
||||||
# Release build
|
# Release build
|
||||||
RUN --mount=type=cache,target=/lemmy/target set -ex; \
|
RUN --mount=type=cache,target=/lemmy/target set -ex; \
|
||||||
if [ "${RUST_RELEASE_MODE}" = "release" ]; then \
|
if [ "${RUST_RELEASE_MODE}" = "release" ]; then \
|
||||||
echo "pub const VERSION: &str = \"$(git describe --tag)\";" > crates/utils/src/version.rs; \
|
|
||||||
[ -z "$USE_RELEASE_CACHE" ] && cargo clean --release; \
|
[ -z "$USE_RELEASE_CACHE" ] && cargo clean --release; \
|
||||||
cargo build --features "${CARGO_BUILD_FEATURES}" --release; \
|
cargo build --features "${CARGO_BUILD_FEATURES}" --release; \
|
||||||
mv target/"${RUST_RELEASE_MODE}"/lemmy_server ./lemmy_server; \
|
mv target/"${RUST_RELEASE_MODE}"/lemmy_server ./lemmy_server; \
|
||||||
|
@ -63,7 +61,6 @@ ENV RUST_RELEASE_MODE=${RUST_RELEASE_MODE} \
|
||||||
# Debug build
|
# Debug build
|
||||||
RUN --mount=type=cache,target=./target,uid=10001,gid=10001 set -ex; \
|
RUN --mount=type=cache,target=./target,uid=10001,gid=10001 set -ex; \
|
||||||
if [ "${RUST_RELEASE_MODE}" = "debug" ]; then \
|
if [ "${RUST_RELEASE_MODE}" = "debug" ]; then \
|
||||||
echo "pub const VERSION: &str = \"$(git describe --tag)\";" > crates/utils/src/version.rs; \
|
|
||||||
cargo build --features "${CARGO_BUILD_FEATURES}"; \
|
cargo build --features "${CARGO_BUILD_FEATURES}"; \
|
||||||
mv "./target/$CARGO_BUILD_TARGET/$RUST_RELEASE_MODE/lemmy_server" /home/lemmy/lemmy_server; \
|
mv "./target/$CARGO_BUILD_TARGET/$RUST_RELEASE_MODE/lemmy_server" /home/lemmy/lemmy_server; \
|
||||||
fi
|
fi
|
||||||
|
@ -71,7 +68,6 @@ RUN --mount=type=cache,target=./target,uid=10001,gid=10001 set -ex; \
|
||||||
# Release build
|
# Release build
|
||||||
RUN --mount=type=cache,target=./target,uid=10001,gid=10001 set -ex; \
|
RUN --mount=type=cache,target=./target,uid=10001,gid=10001 set -ex; \
|
||||||
if [ "${RUST_RELEASE_MODE}" = "release" ]; then \
|
if [ "${RUST_RELEASE_MODE}" = "release" ]; then \
|
||||||
echo "pub const VERSION: &str = \"$(git describe --tag)\";" > crates/utils/src/version.rs; \
|
|
||||||
[ -z "$USE_RELEASE_CACHE" ] && cargo clean --release; \
|
[ -z "$USE_RELEASE_CACHE" ] && cargo clean --release; \
|
||||||
cargo build --features "${CARGO_BUILD_FEATURES}" --release; \
|
cargo build --features "${CARGO_BUILD_FEATURES}" --release; \
|
||||||
mv "./target/$CARGO_BUILD_TARGET/$RUST_RELEASE_MODE/lemmy_server" /home/lemmy/lemmy_server; \
|
mv "./target/$CARGO_BUILD_TARGET/$RUST_RELEASE_MODE/lemmy_server" /home/lemmy/lemmy_server; \
|
||||||
|
|
|
@ -49,7 +49,7 @@ use lemmy_utils::{
|
||||||
rate_limit::RateLimitCell,
|
rate_limit::RateLimitCell,
|
||||||
response::jsonify_plain_text_errors,
|
response::jsonify_plain_text_errors,
|
||||||
settings::{structs::Settings, SETTINGS},
|
settings::{structs::Settings, SETTINGS},
|
||||||
version,
|
VERSION,
|
||||||
};
|
};
|
||||||
use prometheus::default_registry;
|
use prometheus::default_registry;
|
||||||
use prometheus_metrics::serve_prometheus;
|
use prometheus_metrics::serve_prometheus;
|
||||||
|
@ -109,7 +109,7 @@ pub struct CmdArgs {
|
||||||
/// Placing the main function in lib.rs allows other crates to import it and embed Lemmy
|
/// Placing the main function in lib.rs allows other crates to import it and embed Lemmy
|
||||||
pub async fn start_lemmy_server(args: CmdArgs) -> Result<(), LemmyError> {
|
pub async fn start_lemmy_server(args: CmdArgs) -> Result<(), LemmyError> {
|
||||||
// Print version number to log
|
// Print version number to log
|
||||||
println!("Lemmy v{}", version::VERSION);
|
println!("Lemmy v{VERSION}");
|
||||||
|
|
||||||
// return error 503 while running db migrations and startup tasks
|
// return error 503 while running db migrations and startup tasks
|
||||||
let mut startup_server_handle = None;
|
let mut startup_server_handle = None;
|
||||||
|
|
Loading…
Reference in a new issue