diff --git a/Cargo.lock b/Cargo.lock index 1733c0ad7..f6f3e7d4c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -378,7 +378,6 @@ dependencies = [ "iron 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "kuchiki 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.70 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mime_guess 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "notify 4.0.15 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index f99451767..7d7270ca4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -67,8 +67,6 @@ chrono = { version = "0.4.11", features = ["serde"] } time = "0.1" # TODO: Remove once `iron` is removed [target.'cfg(not(windows))'.dependencies] -libc = "0.2" - # Process information procfs = "0.7" diff --git a/README.md b/README.md index 9d06c516b..7ca09c21a 100644 --- a/README.md +++ b/README.md @@ -202,7 +202,7 @@ docker-compose run web database blacklist remove # Run a persistent daemon which queues builds and starts a web server. # Warning: This will try to queue hundreds of packages on crates.io, only start it # if you have enough resources! -docker-compose run -p 3000:3000 web daemon --foreground +docker-compose run -p 3000:3000 web daemon ``` ### Changing the build environment diff --git a/src/bin/cratesfyi.rs b/src/bin/cratesfyi.rs index f91bb4d20..cc374611f 100644 --- a/src/bin/cratesfyi.rs +++ b/src/bin/cratesfyi.rs @@ -62,7 +62,7 @@ enum CommandLine { /// Starts cratesfyi daemon Daemon { - /// Run the server in the foreground instead of detaching a child + /// Deprecated. Run the server in the foreground instead of detaching a child #[structopt(name = "FOREGROUND", short = "f", long = "foreground")] foreground: bool, }, @@ -93,7 +93,11 @@ impl CommandLine { Server::start(Some(&socket_addr), reload_templates, config)?; } Self::Daemon { foreground } => { - cratesfyi::utils::start_daemon(!foreground, config)?; + if foreground { + log::warn!("--foreground was passed, but there is no need for it anymore"); + } + + cratesfyi::utils::start_daemon(config)?; } Self::Database { subcommand } => subcommand.handle_args(), Self::Queue { subcommand } => subcommand.handle_args(), diff --git a/src/utils/daemon.rs b/src/utils/daemon.rs index 5aec1747d..82c56b353 100644 --- a/src/utils/daemon.rs +++ b/src/utils/daemon.rs @@ -16,10 +16,7 @@ use std::sync::Arc; use std::time::Duration; use std::{env, thread}; -#[cfg(not(target_os = "windows"))] -use ::{libc::fork, std::fs::File, std::io::Write, std::process::exit}; - -pub fn start_daemon(background: bool, config: Arc) -> Result<(), Error> { +pub fn start_daemon(config: Arc) -> Result<(), Error> { const CRATE_VARIABLES: [&str; 3] = [ "CRATESFYI_PREFIX", "CRATESFYI_GITHUB_USERNAME", @@ -38,31 +35,6 @@ pub fn start_daemon(background: bool, config: Arc) -> Result<(), Error> // check paths once dbopts.check_paths().unwrap(); - if background { - #[cfg(target_os = "windows")] - { - panic!("running in background not supported on windows"); - } - - #[cfg(not(target_os = "windows"))] - { - // fork the process - let pid = unsafe { fork() }; - if pid > 0 { - let mut file = File::create(dbopts.prefix.join("cratesfyi.pid")) - .expect("Failed to create pid file"); - writeln!(&mut file, "{}", pid).expect("Failed to write pid"); - - info!( - "cratesfyi {} daemon started on: {}", - crate::BUILD_VERSION, - pid - ); - exit(0); - } - } - } - // check new crates every minute thread::Builder::new() .name("registry index reader".to_string())