Skip to content

Commit

Permalink
fix cfg windows for daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyukang committed Nov 22, 2023
1 parent 5998b64 commit 50d4e87
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ckb-bin/src/helper.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ckb_logger::{debug, info};
use ckb_logger::debug;

use std::io::{stdin, stdout, Write};

Expand Down
12 changes: 6 additions & 6 deletions ckb-bin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ use colored::Colorize;
use daemonize::Daemonize;
use helper::raise_fd_limit;
use setup_guard::SetupGuard;

#[cfg(not(target_os = "windows"))]
use subcommand::check_process;

#[cfg(feature = "with_sentry")]
Expand Down Expand Up @@ -127,6 +129,7 @@ fn run_app_inner(
cli::CMD_STATS => subcommand::stats(setup.stats(matches)?, handle.clone()),
cli::CMD_RESET_DATA => subcommand::reset_data(setup.reset_data(matches)?),
cli::CMD_MIGRATE => subcommand::migrate(setup.migrate(matches)?),
#[cfg(not(target_os = "windows"))]
cli::CMD_DAEMON => subcommand::daemon(setup.daemon(matches)?),
_ => unreachable!(),
};
Expand All @@ -144,13 +147,10 @@ fn run_app_inner(
ret
}

#[cfg(target_os = "windows")]
fn run_deamon(_cmd: &str, _matches: &ArgMatches) -> bool {
false
}

#[cfg(not(target_os = "windows"))]
fn run_deamon(cmd: &str, matches: &ArgMatches) -> bool {
#[cfg(target_os = "windows")]
return false;

match cmd {
cli::CMD_RUN | cli::CMD_MINER => matches.get_flag(cli::ARG_DAEMON),
_ => false,
Expand Down
2 changes: 2 additions & 0 deletions ckb-bin/src/subcommand/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(not(target_os = "windows"))]
mod daemon;
mod export;
mod import;
Expand All @@ -11,6 +12,7 @@ mod reset_data;
mod run;
mod stats;

#[cfg(not(target_os = "windows"))]
pub use self::daemon::{check_process, daemon};
pub use self::export::export;
pub use self::import::import;
Expand Down
11 changes: 8 additions & 3 deletions util/app-config/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const GROUP_BA: &str = "ba";

/// return root clap Command
pub fn basic_app() -> Command {
Command::new(BIN_NAME)
let command = Command::new(BIN_NAME)
.author("Nervos Core Dev <dev@nervos.org>")
.about("Nervos CKB - The Common Knowledge Base")
.subcommand_required(true)
Expand All @@ -150,8 +150,12 @@ pub fn basic_app() -> Command {
.subcommand(stats())
.subcommand(reset_data())
.subcommand(peer_id())
.subcommand(migrate())
.subcommand(daemon())
.subcommand(migrate());

#[cfg(not(target_os = "windows"))]
let command = command.subcommand(daemon());

command
}

/// Parse the command line arguments by supplying the version information.
Expand Down Expand Up @@ -398,6 +402,7 @@ fn migrate() -> Command {
)
}

#[cfg(not(target_os = "windows"))]
fn daemon() -> Command {
Command::new(CMD_DAEMON)
.about("Runs ckb daemon command")
Expand Down

0 comments on commit 50d4e87

Please sign in to comment.