Browse Source

fixed windows build failing due to deemonize

Signed-off-by: Karan Gauswami <[email protected]>
pull/30/head
Karan Gauswami 4 months ago
parent
commit
07f7a0c5af
No known key found for this signature in database GPG Key ID: 4457EA801DBC82E6
  1. 2
      Cargo.lock
  2. 4
      Cargo.toml
  3. 13
      src/main.rs

2
Cargo.lock

@ -1260,7 +1260,7 @@ checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
[[package]]
name = "sthp"
version = "0.5.0-beta1"
version = "0.5.0-beta2"
dependencies = [
"base64",
"bytes",

4
Cargo.toml

@ -1,6 +1,6 @@
[package]
name = "sthp"
version = "0.5.0-beta1"
version = "0.5.0-beta2"
license = "MIT"
authors = ["Karan Gauswami <[email protected]>"]
edition = "2021"
@ -22,6 +22,8 @@ tracing = "0.1.37"
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
hyper-util = { version="0.1.5",features = ["tokio"] }
base64 = "0.22.1"
[target.'cfg(not(windows))'.dependencies]
daemonize = "0.5.0"
[dev-dependencies]

13
src/main.rs

@ -10,7 +10,6 @@ use std::net::{IpAddr, SocketAddr, ToSocketAddrs};
use base64::engine::general_purpose;
use base64::Engine;
use daemonize::Daemonize;
use hyper::header::HeaderValue;
use tokio::net::TcpListener;
@ -57,6 +56,7 @@ struct Cli {
#[arg(long)]
http_basic: Option<String>,
#[cfg(not(target_os = "windows"))]
/// Run process in background
#[arg(short, long, default_value_t = false)]
detached: bool,
@ -88,10 +88,13 @@ async fn main() -> Result<()> {
let listener = TcpListener::bind(addr).await?;
let daemonize = Daemonize::new();
if args.detached {
if let Err(e) = daemonize.start() {
eprintln!("Error: {}", e);
#[cfg(not(target_os = "windows"))]
{
if args.detached {
let daemonize = daemonize::Daemonize::new();
if let Err(e) = daemonize.start() {
eprintln!("Error: {}", e);
}
}
}

Loading…
Cancel
Save