mirror of
https://git.asonix.dog/asonix/pict-rs
synced 2024-12-22 11:21:24 +00:00
Allow configuring console buffer capacity
This commit is contained in:
parent
bd26c60cd5
commit
62615be371
6 changed files with 44 additions and 15 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1580,7 +1580,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pict-rs"
|
name = "pict-rs"
|
||||||
version = "0.3.0-rc.5"
|
version = "0.3.0-rc.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"actix-form-data",
|
"actix-form-data",
|
||||||
"actix-rt",
|
"actix-rt",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "pict-rs"
|
name = "pict-rs"
|
||||||
description = "A simple image hosting service"
|
description = "A simple image hosting service"
|
||||||
version = "0.3.0-rc.5"
|
version = "0.3.0-rc.6"
|
||||||
authors = ["asonix <asonix@asonix.dog>"]
|
authors = ["asonix <asonix@asonix.dog>"]
|
||||||
license = "AGPL-3.0"
|
license = "AGPL-3.0"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
29
README.md
29
README.md
|
@ -9,7 +9,7 @@ _a simple image hosting service_
|
||||||
## Usage
|
## Usage
|
||||||
### Running
|
### Running
|
||||||
```
|
```
|
||||||
pict-rs 0.3.0-rc.5
|
pict-rs 0.3.0-rc.6
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
pict-rs [FLAGS] [OPTIONS] [SUBCOMMAND]
|
pict-rs [FLAGS] [OPTIONS] [SUBCOMMAND]
|
||||||
|
@ -20,32 +20,39 @@ FLAGS:
|
||||||
-V, --version Prints version information
|
-V, --version Prints version information
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-a, --addr <addr> The address and port the server binds to.
|
-a, --addr <addr> The address and port the server binds to.
|
||||||
--api-key <api-key>
|
--api-key <api-key>
|
||||||
An optional string to be checked on requests to privileged endpoints
|
An optional string to be checked on requests to privileged endpoints
|
||||||
|
|
||||||
-c, --config-file <config-file> Path to the pict-rs configuration file
|
-c, --config-file <config-file> Path to the pict-rs configuration file
|
||||||
|
--console-buffer-capacity <console-buffer-capacity>
|
||||||
|
Specify the number of events the console subscriber is allowed to buffer
|
||||||
|
|
||||||
-f, --filters <filters>...
|
-f, --filters <filters>...
|
||||||
An optional list of filters to permit, supports 'identity', 'thumbnail', 'resize', 'crop', and 'blur'
|
An optional list of filters to permit, supports 'identity', 'thumbnail', 'resize', 'crop', and 'blur'
|
||||||
|
|
||||||
-i, --image-format <image-format>
|
-i, --image-format <image-format>
|
||||||
An optional image format to convert all uploaded files into, supports 'jpg', 'png', and 'webp'
|
An optional image format to convert all uploaded files into, supports 'jpg', 'png', and 'webp'
|
||||||
|
|
||||||
-m, --max-file-size <max-file-size> Specify the maximum allowed uploaded file size (in Megabytes)
|
-m, --max-file-size <max-file-size>
|
||||||
--max-image-area <max-image-area> Specify the maximum area in pixels allowed in an image
|
Specify the maximum allowed uploaded file size (in Megabytes)
|
||||||
--max-image-height <max-image-height> Specify the maximum width in pixels allowed on an image
|
|
||||||
--max-image-width <max-image-width> Specify the maximum width in pixels allowed on an image
|
--max-image-area <max-image-area> Specify the maximum area in pixels allowed in an image
|
||||||
--migrate-file <migrate-file> Path to a file defining a store migration
|
--max-image-height <max-image-height> Specify the maximum width in pixels allowed on an image
|
||||||
|
--max-image-width <max-image-width> Specify the maximum width in pixels allowed on an image
|
||||||
|
--migrate-file <migrate-file> Path to a file defining a store migration
|
||||||
-o, --opentelemetry-url <opentelemetry-url>
|
-o, --opentelemetry-url <opentelemetry-url>
|
||||||
Enable OpenTelemetry Tracing exports to the given OpenTelemetry collector
|
Enable OpenTelemetry Tracing exports to the given OpenTelemetry collector
|
||||||
|
|
||||||
-p, --path <path> The path to the data directory, e.g. data/
|
-p, --path <path> The path to the data directory, e.g. data/
|
||||||
--sled-cache-capacity <sled-cache-capacity> Specify the number of bytes sled is allowed to use for it's cache
|
--sled-cache-capacity <sled-cache-capacity>
|
||||||
|
Specify the number of bytes sled is allowed to use for it's cache
|
||||||
|
|
||||||
|
|
||||||
SUBCOMMANDS:
|
SUBCOMMANDS:
|
||||||
file-store
|
file-store
|
||||||
help Prints this message or the help of the given subcommand(s)
|
help Prints this message or the help of the given subcommand(s)
|
||||||
s3-store
|
s3-store
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
|
@ -82,6 +82,13 @@ pub(crate) struct Overrides {
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
sled_cache_capacity: Option<u64>,
|
sled_cache_capacity: Option<u64>,
|
||||||
|
|
||||||
|
#[structopt(
|
||||||
|
long,
|
||||||
|
help = "Specify the number of events the console subscriber is allowed to buffer"
|
||||||
|
)]
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
console_buffer_capacity: Option<usize>,
|
||||||
|
|
||||||
#[structopt(
|
#[structopt(
|
||||||
long,
|
long,
|
||||||
help = "An optional string to be checked on requests to privileged endpoints"
|
help = "An optional string to be checked on requests to privileged endpoints"
|
||||||
|
@ -114,6 +121,7 @@ impl Overrides {
|
||||||
&& self.max_image_height.is_none()
|
&& self.max_image_height.is_none()
|
||||||
&& self.max_image_area.is_none()
|
&& self.max_image_area.is_none()
|
||||||
&& self.sled_cache_capacity.is_none()
|
&& self.sled_cache_capacity.is_none()
|
||||||
|
&& self.console_buffer_capacity.is_none()
|
||||||
&& self.api_key.is_none()
|
&& self.api_key.is_none()
|
||||||
&& self.opentelemetry_url.is_none()
|
&& self.opentelemetry_url.is_none()
|
||||||
&& self.store.is_none()
|
&& self.store.is_none()
|
||||||
|
@ -192,6 +200,7 @@ pub(crate) struct Config {
|
||||||
max_image_height: usize,
|
max_image_height: usize,
|
||||||
max_image_area: usize,
|
max_image_area: usize,
|
||||||
sled_cache_capacity: u64,
|
sled_cache_capacity: u64,
|
||||||
|
console_buffer_capacity: usize,
|
||||||
api_key: Option<String>,
|
api_key: Option<String>,
|
||||||
opentelemetry_url: Option<Url>,
|
opentelemetry_url: Option<Url>,
|
||||||
store: Store,
|
store: Store,
|
||||||
|
@ -207,6 +216,7 @@ pub(crate) struct Defaults {
|
||||||
max_image_height: usize,
|
max_image_height: usize,
|
||||||
max_image_area: usize,
|
max_image_area: usize,
|
||||||
sled_cache_capacity: u64,
|
sled_cache_capacity: u64,
|
||||||
|
console_buffer_capacity: usize,
|
||||||
store: Store,
|
store: Store,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,6 +230,7 @@ impl Defaults {
|
||||||
max_image_height: 10_000,
|
max_image_height: 10_000,
|
||||||
max_image_area: 40_000_000,
|
max_image_area: 40_000_000,
|
||||||
sled_cache_capacity: 1024 * 1024 * 64, // 16 times smaller than sled's default of 1GB
|
sled_cache_capacity: 1024 * 1024 * 64, // 16 times smaller than sled's default of 1GB
|
||||||
|
console_buffer_capacity: 1024 * 128,
|
||||||
store: Store::FileStore { path: None },
|
store: Store::FileStore { path: None },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -275,6 +286,11 @@ impl Config {
|
||||||
self.sled_cache_capacity
|
self.sled_cache_capacity
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "console")]
|
||||||
|
pub(crate) fn console_buffer_capacity(&self) -> usize {
|
||||||
|
self.console_buffer_capacity
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn format(&self) -> Option<Format> {
|
pub(crate) fn format(&self) -> Option<Format> {
|
||||||
self.image_format
|
self.image_format
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ use url::Url;
|
||||||
pub(super) fn init_tracing(
|
pub(super) fn init_tracing(
|
||||||
servic_name: &'static str,
|
servic_name: &'static str,
|
||||||
opentelemetry_url: Option<&Url>,
|
opentelemetry_url: Option<&Url>,
|
||||||
|
#[cfg(feature = "console")] buffer_capacity: usize,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
LogTracer::init()?;
|
LogTracer::init()?;
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ pub(super) fn init_tracing(
|
||||||
#[cfg(feature = "console")]
|
#[cfg(feature = "console")]
|
||||||
let console_layer = ConsoleLayer::builder()
|
let console_layer = ConsoleLayer::builder()
|
||||||
.with_default_env()
|
.with_default_env()
|
||||||
.event_buffer_capacity(1024 * 1024)
|
.event_buffer_capacity(buffer_capacity)
|
||||||
.server_addr(([0, 0, 0, 0], 6669))
|
.server_addr(([0, 0, 0, 0], 6669))
|
||||||
.spawn();
|
.spawn();
|
||||||
|
|
||||||
|
|
|
@ -882,7 +882,12 @@ where
|
||||||
|
|
||||||
#[actix_rt::main]
|
#[actix_rt::main]
|
||||||
async fn main() -> anyhow::Result<()> {
|
async fn main() -> anyhow::Result<()> {
|
||||||
init_tracing("pict-rs", CONFIG.opentelemetry_url())?;
|
init_tracing(
|
||||||
|
"pict-rs",
|
||||||
|
CONFIG.opentelemetry_url(),
|
||||||
|
#[cfg(feature = "console")]
|
||||||
|
CONFIG.console_buffer_capacity(),
|
||||||
|
)?;
|
||||||
|
|
||||||
let db = LatestDb::exists(CONFIG.data_dir(), CONFIG.sled_cache_capacity()).migrate()?;
|
let db = LatestDb::exists(CONFIG.data_dir(), CONFIG.sled_cache_capacity()).migrate()?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue