Skip to content

Commit

Permalink
Make registry-watcher flag a enable/disable toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemo157 authored and Joshua Nelson committed Jul 5, 2020
1 parent 73566d0 commit 914e365
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 5 deletions.
22 changes: 22 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ git2 = { version = "0.13.6", default-features = false }
path-slash = "0.1.3"
once_cell = { version = "1.4.0", features = ["parking_lot"] }
base64 = "0.12.1"
strum = { version = "0.18.0", features = ["derive"] }

# Data serialization and deserialization
serde = { version = "1.0", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ COPY dockerfiles/entrypoint.sh /opt/docsrs/

WORKDIR /opt/docsrs
ENTRYPOINT ["/opt/docsrs/entrypoint.sh"]
CMD ["daemon", "--disable-registry-watcher"]
CMD ["daemon", "--registry-watcher=disabled"]
21 changes: 17 additions & 4 deletions src/bin/cratesfyi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use cratesfyi::{BuildQueue, Config, DocBuilder, DocBuilderOptions, RustwideBuild
use failure::Error;
use once_cell::sync::OnceCell;
use structopt::StructOpt;
use strum::VariantNames;

pub fn main() -> Result<(), Error> {
let _ = dotenv::dotenv();
Expand Down Expand Up @@ -40,6 +41,13 @@ fn logger_init() {
rustwide::logging::init_with(builder.build());
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, strum::EnumString, strum::EnumVariantNames)]
#[strum(serialize_all = "snake_case")]
enum Toggle {
Enabled,
Disabled,
}

#[derive(Debug, Clone, PartialEq, Eq, StructOpt)]
#[structopt(
name = "cratesfyi",
Expand All @@ -66,8 +74,13 @@ enum CommandLine {
#[structopt(name = "FOREGROUND", short = "f", long = "foreground")]
foreground: bool,

#[structopt(long = "disable-registry-watcher")]
disable_registry_watcher: bool,
/// Enable or disable the registry watcher to automatically enqueue newly published crates
#[structopt(
long = "registry-watcher",
default_value = "enabled",
possible_values(Toggle::VARIANTS)
)]
registry_watcher: Toggle,
},

/// Database operations
Expand Down Expand Up @@ -103,7 +116,7 @@ impl CommandLine {
}
Self::Daemon {
foreground,
disable_registry_watcher,
registry_watcher,
} => {
if foreground {
log::warn!("--foreground was passed, but there is no need for it anymore");
Expand All @@ -113,7 +126,7 @@ impl CommandLine {
ctx.config()?,
ctx.pool()?,
ctx.build_queue()?,
!disable_registry_watcher,
registry_watcher == Toggle::Enabled,
)?;
}
Self::Database { subcommand } => subcommand.handle_args(ctx)?,
Expand Down

0 comments on commit 914e365

Please sign in to comment.