Compare commits

..

No commits in common. "ada434032b59593d617cc75b2ef2d0584d0b9f17" and "023dffe70c9d52e5887c170718a1eacb49eaba08" have entirely different histories.

6 changed files with 213 additions and 244 deletions

99
Cargo.lock generated
View File

@ -20,15 +20,6 @@ dependencies = [
"tracing-futures", "tracing-futures",
] ]
[[package]]
name = "addr2line"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb"
dependencies = [
"gimli",
]
[[package]] [[package]]
name = "adler" name = "adler"
version = "1.0.2" version = "1.0.2"
@ -149,21 +140,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "backtrace"
version = "0.3.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837"
dependencies = [
"addr2line",
"cc",
"cfg-if",
"libc",
"miniz_oxide",
"object",
"rustc-demangle",
]
[[package]] [[package]]
name = "base64" name = "base64"
version = "0.13.1" version = "0.13.1"
@ -527,6 +503,7 @@ dependencies = [
"serde_yaml", "serde_yaml",
"sha2", "sha2",
"signal-hook", "signal-hook",
"signal-hook-tokio",
"tempdir", "tempdir",
"thiserror", "thiserror",
"tls-listener", "tls-listener",
@ -831,12 +808,6 @@ dependencies = [
"wasi", "wasi",
] ]
[[package]]
name = "gimli"
version = "0.28.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0"
[[package]] [[package]]
name = "gix" name = "gix"
version = "0.44.1" version = "0.44.1"
@ -1599,7 +1570,7 @@ dependencies = [
"httpdate", "httpdate",
"itoa", "itoa",
"pin-project-lite", "pin-project-lite",
"socket2 0.4.9", "socket2",
"tokio", "tokio",
"tower-service", "tower-service",
"tracing", "tracing",
@ -1761,7 +1732,7 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd302af1b90f2463a98fa5ad469fc212c8e3175a41c3068601bfa2727591c5be" checksum = "bd302af1b90f2463a98fa5ad469fc212c8e3175a41c3068601bfa2727591c5be"
dependencies = [ dependencies = [
"socket2 0.4.9", "socket2",
"widestring", "widestring",
"winapi", "winapi",
"winreg", "winreg",
@ -1849,9 +1820,9 @@ dependencies = [
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.150" version = "0.2.142"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317"
[[package]] [[package]]
name = "linked-hash-map" name = "linked-hash-map"
@ -1970,13 +1941,14 @@ dependencies = [
[[package]] [[package]]
name = "mio" name = "mio"
version = "0.8.9" version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9"
dependencies = [ dependencies = [
"libc", "libc",
"log",
"wasi", "wasi",
"windows-sys 0.48.0", "windows-sys 0.45.0",
] ]
[[package]] [[package]]
@ -2100,15 +2072,6 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "object"
version = "0.32.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0"
dependencies = [
"memchr",
]
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.17.1" version = "1.17.1"
@ -2270,9 +2233,9 @@ dependencies = [
[[package]] [[package]]
name = "pin-project-lite" name = "pin-project-lite"
version = "0.2.13" version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
[[package]] [[package]]
name = "pin-utils" name = "pin-utils"
@ -2613,12 +2576,6 @@ dependencies = [
"walkdir", "walkdir",
] ]
[[package]]
name = "rustc-demangle"
version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
[[package]] [[package]]
name = "rustix" name = "rustix"
version = "0.37.18" version = "0.37.18"
@ -2847,6 +2804,18 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "signal-hook-tokio"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "213241f76fb1e37e27de3b6aa1b068a2c333233b59cca6634f634b80a27ecf1e"
dependencies = [
"futures-core",
"libc",
"signal-hook",
"tokio",
]
[[package]] [[package]]
name = "slab" name = "slab"
version = "0.4.8" version = "0.4.8"
@ -2872,16 +2841,6 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "socket2"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9"
dependencies = [
"libc",
"windows-sys 0.48.0",
]
[[package]] [[package]]
name = "spin" name = "spin"
version = "0.5.2" version = "0.5.2"
@ -3046,11 +3005,11 @@ dependencies = [
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.34.0" version = "1.28.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9" checksum = "0aa32867d44e6f2ce3385e89dceb990188b8bb0fb25b0cf576647a6f98ac5105"
dependencies = [ dependencies = [
"backtrace", "autocfg",
"bytes", "bytes",
"libc", "libc",
"mio", "mio",
@ -3058,16 +3017,16 @@ dependencies = [
"parking_lot", "parking_lot",
"pin-project-lite", "pin-project-lite",
"signal-hook-registry", "signal-hook-registry",
"socket2 0.5.5", "socket2",
"tokio-macros", "tokio-macros",
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
[[package]] [[package]]
name = "tokio-macros" name = "tokio-macros"
version = "2.2.0" version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View File

@ -20,9 +20,10 @@ serde_json = "1.0.96"
trust-dns-client = "0.22.0" trust-dns-client = "0.22.0"
mockall = "0.11.4" mockall = "0.11.4"
thiserror = "1.0.40" thiserror = "1.0.40"
tokio = { version = "1.34.0", features = ["full", "net", "signal"] } tokio = { version = "1.28.1", features = [ "full", "net" ]}
signal-hook = "0.3.15" signal-hook = "0.3.15"
futures = "0.3.28" futures = "0.3.28"
signal-hook-tokio = { version = "0.3.1", features = [ "futures-v0_3" ]}
clap = { version = "4.2.7", features = ["derive", "env"] } clap = { version = "4.2.7", features = ["derive", "env"] }
handlebars = { version = "4.3.7", features = [ "rust-embed" ]} handlebars = { version = "4.3.7", features = [ "rust-embed" ]}
rust-embed = "6.6.1" rust-embed = "6.6.1"
@ -48,6 +49,4 @@ gemini = "0.0.5"
bytes = "1.4.0" bytes = "1.4.0"
[patch.crates-io] [patch.crates-io]
# The micropelago fork of tokio-rustls allows for gemini proxying
tokio-rustls = { git = "https://code.betamike.com/micropelago/tokio-rustls.git", branch = "start-handshake-into-inner" } tokio-rustls = { git = "https://code.betamike.com/micropelago/tokio-rustls.git", branch = "start-handshake-into-inner" }

View File

@ -1,27 +1,26 @@
{ {
"nodes": { "nodes": {
"fenix": { "flake-utils": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs", "systems": "systems"
"rust-analyzer-src": "rust-analyzer-src"
}, },
"locked": { "locked": {
"lastModified": 1699770036, "lastModified": 1681202837,
"narHash": "sha256-bZmI7ytPAYLpyFNgj5xirDkKuAniOkj1xHdv5aIJ5GM=", "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
"owner": "nix-community", "owner": "numtide",
"repo": "fenix", "repo": "flake-utils",
"rev": "81ab0b4f7ae9ebb57daa0edf119c4891806e4d3a", "rev": "cfacdce06f30d2b68473a46042957675eebb3401",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nix-community", "owner": "numtide",
"repo": "fenix", "repo": "flake-utils",
"type": "github" "type": "github"
} }
}, },
"naersk": { "naersk": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs_2" "nixpkgs": "nixpkgs"
}, },
"locked": { "locked": {
"lastModified": 1690373729, "lastModified": 1690373729,
@ -39,22 +38,6 @@
} }
}, },
"nixpkgs": { "nixpkgs": {
"locked": {
"lastModified": 1699099776,
"narHash": "sha256-X09iKJ27mGsGambGfkKzqvw5esP1L/Rf8H3u3fCqIiU=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "85f1ba3e51676fa8cc604a3d863d729026a6b8eb",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1691003216, "lastModified": 1691003216,
"narHash": "sha256-Qq/MPkhS12Bl0X060pPvX3v9ac3f2rRQfHjjozPh/Qs=", "narHash": "sha256-Qq/MPkhS12Bl0X060pPvX3v9ac3f2rRQfHjjozPh/Qs=",
@ -68,7 +51,7 @@
"type": "indirect" "type": "indirect"
} }
}, },
"nixpkgs_3": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1688392541, "lastModified": 1688392541,
"narHash": "sha256-lHrKvEkCPTUO+7tPfjIcb7Trk6k31rz18vkyqmkeJfY=", "narHash": "sha256-lHrKvEkCPTUO+7tPfjIcb7Trk6k31rz18vkyqmkeJfY=",
@ -84,27 +67,94 @@
"type": "github" "type": "github"
} }
}, },
"root": { "nixpkgs_3": {
"inputs": {
"fenix": "fenix",
"naersk": "naersk",
"nixpkgs": "nixpkgs_3"
}
},
"rust-analyzer-src": {
"flake": false,
"locked": { "locked": {
"lastModified": 1699715108, "lastModified": 1681358109,
"narHash": "sha256-yPozsobJU55gj+szgo4Lpcg1lHvGQYAT6Y4MrC80mWE=", "narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=",
"owner": "rust-lang", "owner": "NixOS",
"repo": "rust-analyzer", "repo": "nixpkgs",
"rev": "5fcf5289e726785d20d3aa4d13d90a43ed248e83", "rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "rust-lang", "owner": "NixOS",
"ref": "nightly", "ref": "nixpkgs-unstable",
"repo": "rust-analyzer", "repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"naersk": "naersk",
"nixpkgs": "nixpkgs_2",
"rust-overlay": "rust-overlay",
"utils": "utils"
}
},
"rust-overlay": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1691029059,
"narHash": "sha256-QwVeE9YTgH3LmL7yw2V/hgswL6yorIvYSp4YGI8lZYM=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "99df4908445be37ddb2d332580365fce512a7dcf",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"utils": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1689068808,
"narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github" "type": "github"
} }
} }

181
flake.nix
View File

@ -1,143 +1,102 @@
{ {
inputs = { inputs = {
fenix.url = "github:nix-community/fenix";
naersk.url = "github:nix-community/naersk/master"; naersk.url = "github:nix-community/naersk/master";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
}; };
outputs = { self, nixpkgs, naersk, fenix }: outputs = { self, nixpkgs, utils, naersk, rust-overlay }:
let let
buildTargets = { buildTargetsBySystem = {
"x86_64-linux" = { "x86_64-linux" = "x86_64-unknown-linux-musl";
crossSystemConfig = "x86_64-unknown-linux-musl"; "i686-linux" = "i686-unknown-linux-musl";
rustTarget = "x86_64-unknown-linux-musl"; "aarch64-linux" = "aarch64-unknown-linux-musl";
}; };
"i686-linux" = { supportedSystems = builtins.attrNames buildTargetsBySystem;
crossSystemConfig = "i686-unknown-linux-musl";
rustTarget = "i686-unknown-linux-musl";
};
"aarch64-linux" = { eachCrossSystem = callback: (builtins.foldl'
crossSystemConfig = "aarch64-unknown-linux-musl"; (overall: buildSystem: overall // {
rustTarget = "aarch64-unknown-linux-musl"; ${buildSystem} = (builtins.foldl'
}; (inner: hostSystem: inner // {
"cross-${hostSystem}" = callback buildSystem hostSystem;
"x86_64-windows" = {
crossSystemConfig = "x86_64-w64-mingw32";
rustTarget = "x86_64-pc-windows-gnu";
makeBuildPackageAttrs = pkgsCross: {
depsBuildBuild = [
pkgsCross.stdenv.cc
pkgsCross.windows.pthreads
];
};
};
};
# eachSystem [system] (system: ...)
#
# Returns an attrset with a key for every system in the given array, with
# the key's value being the result of calling the callback with that key.
eachSystem = supportedSystems: callback: builtins.foldl'
(overall: system: overall // { ${system} = callback system; })
{}
supportedSystems;
# eachCrossSystem [system] (buildSystem: targetSystem: ...)
#
# Returns an attrset with a key "$buildSystem.cross-$targetSystem" for
# every combination of the elements of the array of system strings. The
# value of the attrs will be the result of calling the callback with each
# combination.
#
# There will also be keys "$system.default", which are aliases of
# "$system.cross-$system" for every system.
#
eachCrossSystem = supportedSystems: callback:
eachSystem supportedSystems (buildSystem: builtins.foldl'
(inner: targetSystem: inner // {
"cross-${targetSystem}" = callback buildSystem targetSystem;
}) })
{ default = callback buildSystem buildSystem; } { default = callback buildSystem buildSystem; }
supportedSystems supportedSystems
); );
})
{}
supportedSystems
);
mkPkgs = buildSystem: targetSystem: import nixpkgs ({ mkPkgs = buildSystem: hostSystem: import nixpkgs ({
system = buildSystem; system = buildSystem;
} // (if targetSystem == null then {} else { overlays = [
(import rust-overlay)
(final: prev: {
rust-toolchain = prev.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
})
];
} // (if buildSystem == hostSystem then {} else {
# The nixpkgs cache doesn't have any packages where cross-compiling has # The nixpkgs cache doesn't have any packages where cross-compiling has
# been enabled, even if the target platform is actually the same as the # been enabled, even if the target platform is actually the same as the
# build platform (and therefore it's not really cross-compiling). So we # build platform (and therefore it's not really cross-compiling). So we
# only set up the cross-compiling config if the target platform is # only set up the cross-compiling config if the target platform is
# different. # different.
crossSystem.config = buildTargets.${targetSystem}.crossSystemConfig; crossSystem.config = hostSystem;
})); }));
in { mkRustEnv = crossPkgs: hostSystem: {
packages = eachCrossSystem OPENSSL_STATIC = "1";
(builtins.attrNames buildTargets) OPENSSL_LIB_DIR = "${crossPkgs.pkgsStatic.openssl.out}/lib";
(buildSystem: targetSystem: let OPENSSL_INCLUDE_DIR = "${crossPkgs.pkgsStatic.openssl.dev}/include";
pkgs = mkPkgs buildSystem null; CARGO_BUILD_TARGET = buildTargetsBySystem.${hostSystem};
pkgsCross = mkPkgs buildSystem targetSystem; CARGO_BUILD_RUSTFLAGS = [
rustTarget = buildTargets.${targetSystem}.rustTarget; "-C" "target-feature=+crt-static"
"-C" "linker=${crossPkgs.stdenv.cc}/bin/${crossPkgs.stdenv.cc.targetPrefix}cc"
# TODO I'd prefer to use the toolchain file "-C" "link-arg=-static"
# https://github.com/nix-community/fenix/issues/123
#toolchain = fenix.packages.${buildSystem}.fromToolchainFile {
# file = ./rust-toolchain.toml;
# sha256 = "sha256-LU4C/i+maIOqBZagUaXpFyWZyOVfQ3Ah5/JTz7v6CG4=";
#};
fenixPkgs = fenix.packages.${buildSystem};
mkToolchain = fenixPkgs: fenixPkgs.toolchainOf {
channel = "nightly";
date = "2023-07-23";
sha256 = "sha256-LU4C/i+maIOqBZagUaXpFyWZyOVfQ3Ah5/JTz7v6CG4=";
};
toolchain = fenixPkgs.combine [
(mkToolchain fenixPkgs).rustc
(mkToolchain fenixPkgs).cargo
(mkToolchain fenixPkgs.targets.${rustTarget}).rust-std
]; ];
buildPackageAttrs = if
builtins.hasAttr "makeBuildPackageAttrs" buildTargets.${targetSystem}
then
buildTargets.${targetSystem}.makeBuildPackageAttrs pkgsCross
else
{};
naersk-lib = pkgs.callPackage naersk {
cargo = toolchain;
rustc = toolchain;
}; };
in in
naersk-lib.buildPackage (buildPackageAttrs // rec { {
packages = eachCrossSystem (buildSystem: hostSystem: let
pkgs = mkPkgs buildSystem buildSystem;
crossPkgs = mkPkgs buildSystem hostSystem;
naersk-lib = pkgs.callPackage naersk {
cargo = pkgs.rust-toolchain;
rustc = pkgs.rust-toolchain;
};
rustEnv = mkRustEnv crossPkgs hostSystem;
in
naersk-lib.buildPackage ({
src = ./.; src = ./.;
strictDeps = true;
doCheck = false; doCheck = false;
nativeBuildInputs = [ crossPkgs.pkgsStatic.stdenv.cc ];
OPENSSL_STATIC = "1"; } // rustEnv)
OPENSSL_LIB_DIR = "${pkgsCross.pkgsStatic.openssl.out}/lib";
OPENSSL_INCLUDE_DIR = "${pkgsCross.pkgsStatic.openssl.dev}/include";
# Required because ring crate is special. This also seems to have
# fixed some issues with the x86_64-windows cross-compile :shrug:
TARGET_CC="${pkgsCross.stdenv.cc}/bin/${pkgsCross.stdenv.cc.targetPrefix}cc";
CARGO_BUILD_TARGET = rustTarget;
CARGO_BUILD_RUSTFLAGS = [
"-C" "target-feature=+crt-static"
"-C" "link-arg=-static"
# https://github.com/rust-lang/cargo/issues/4133
"-C" "linker=${TARGET_CC}"
];
})
); );
devShells = eachCrossSystem (buildSystem: hostSystem: let
pkgs = mkPkgs buildSystem buildSystem;
crossPkgs = mkPkgs buildSystem hostSystem;
rustEnv = mkRustEnv crossPkgs hostSystem;
in
pkgs.mkShell ({
nativeBuildInputs = [
crossPkgs.stdenv.cc
crossPkgs.openssl
pkgs.nmap # ncat
pkgs.rust-toolchain
];
shellHook = ''
export CARGO_HOME=$(pwd)/.cargo
if [ -f "config.yml" ]; then
export DOMANI_CONFIG_PATH=config-dev.yml
fi
'';
} // rustEnv));
}; };
} }

View File

@ -4,6 +4,5 @@ components = [ "rustfmt", "rustc-dev", "clippy", "cargo" ]
targets = [ targets = [
"x86_64-unknown-linux-musl", "x86_64-unknown-linux-musl",
"i686-unknown-linux-musl", "i686-unknown-linux-musl",
"aarch64-unknown-linux-musl", "aarch64-unknown-linux-musl"
"x86_64-pc-windows-gnu"
] ]

View File

@ -1,6 +1,9 @@
#![feature(trait_upcasting)] #![feature(trait_upcasting)]
use clap::Parser; use clap::Parser;
use futures::stream::StreamExt;
use signal_hook_tokio::Signals;
use std::path; use std::path;
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
@ -192,18 +195,18 @@ async fn main() {
); );
} }
tokio::signal::ctrl_c() let mut signals =
.await Signals::new(signal_hook::consts::TERM_SIGNALS).expect("initializing signals failed");
.expect("failed to listen for kill signal");
if (signals.next().await).is_some() {
log::info!("Gracefully shutting down..."); log::info!("Gracefully shutting down...");
}
tokio::spawn(async move { tokio::spawn(async move {
tokio::signal::ctrl_c() if (signals.next().await).is_some() {
.await
.expect("failed to listen for kill signal");
log::warn!("Forcefully shutting down"); log::warn!("Forcefully shutting down");
std::process::exit(1); std::process::exit(1);
};
}); });
task_stack task_stack