Skip to content

Commit

Permalink
Store snapshots in their own path
Browse files Browse the repository at this point in the history
  • Loading branch information
ezrasingh committed Aug 23, 2024
1 parent 37ce551 commit b12f64d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion contrib/docker/quickstart/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:
- ${HOST_PORT:-5000}:5000
volumes:
- ./geoprox.toml:/var/lib/geoprox/geoprox.toml:ro
- ./snapshots/snapshot.bin:/var/lib/geoprox/snapshot.bin:z
- ./snapshots:/var/lib/geoprox/snapshots:z

# Here is an example to generate just the OpenAPI spec
geoprox-spec:
Expand Down
2 changes: 1 addition & 1 deletion contrib/docker/quickstart/geoprox.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ default_sorted = false
# Toggle snapshot usage
disabled = false
# Directory where snapshots will be stored
path = '/var/lib/geoprox'
path = '/var/lib/geoprox/snapshots'
# How often snapshots will be taken
every = '30s'
9 changes: 6 additions & 3 deletions geoprox-server/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,21 @@ pub struct SnapshotConfig {
/// Toggles snapshot usage
#[serde(default)]
pub disabled: bool,
/// Directory where snapshots will be stored and read from (default /var/lib/geoprox)
/// Directory where snapshots will be stored and read from (default /var/lib/geoprox/snapshots)
pub path: Option<PathBuf>,
/// Determines how often snapshots will be taken (default 60s)
pub every: Option<DurationString>,
}

impl SnapshotConfig {
pub const SNAPSHOT_FILENAME: &'static str = "snapshot.bin";
fn default_path() -> PathBuf {
PathBuf::from(DEFAULT_CONFIG_PATH).join("snapshots")
}
pub fn bin_path(&self) -> PathBuf {
self.path
.clone()
.unwrap_or(PathBuf::from(DEFAULT_CONFIG_PATH))
.unwrap_or(Self::default_path())
.join(Self::SNAPSHOT_FILENAME)
}
}
Expand All @@ -33,7 +36,7 @@ impl Default for SnapshotConfig {
fn default() -> Self {
Self {
disabled: false,
path: Some(PathBuf::from(DEFAULT_CONFIG_PATH)),
path: Some(Self::default_path()),
every: Some(DurationString::default()),
}
}
Expand Down
2 changes: 1 addition & 1 deletion geoprox/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ default_sorted = false
# Toggle snapshot usage
disabled = false
# Directory where snapshots will be stored
path = '/var/lib/geoprox'
path = '/var/lib/geoprox/snapshots'
# How often snapshots will be taken
every = '30s'
```
Expand Down

0 comments on commit b12f64d

Please sign in to comment.