mirror of
https://codeberg.org/icewind/palantir.git
synced 2026-06-03 10:14:09 +02:00
allow disabling mdns
This commit is contained in:
parent
d2ee4300ab
commit
844b4edae0
4 changed files with 23 additions and 6 deletions
1
.envrc
Normal file
1
.envrc
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
use flake
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,3 +1,4 @@
|
||||||
/target
|
/target
|
||||||
/result
|
/result
|
||||||
|
.direnv
|
||||||
.env
|
.env
|
||||||
|
|
|
||||||
15
flake.nix
15
flake.nix
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
# `nix develop`
|
# `nix develop`
|
||||||
devShell = pkgs.mkShell {
|
devShell = pkgs.mkShell {
|
||||||
nativeBuildInputs = with pkgs; [rustc cargo];
|
nativeBuildInputs = with pkgs; [rustc cargo bacon];
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
// {
|
// {
|
||||||
|
|
@ -71,6 +71,13 @@
|
||||||
description = "enable docker integration";
|
description = "enable docker integration";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mdns = mkOption rec {
|
||||||
|
type = types.bool;
|
||||||
|
default = true;
|
||||||
|
example = true;
|
||||||
|
description = "enable mdns discovery";
|
||||||
|
};
|
||||||
|
|
||||||
openPort = mkOption rec {
|
openPort = mkOption rec {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
|
|
@ -103,6 +110,11 @@
|
||||||
systemd.services."palantir" = {
|
systemd.services."palantir" = {
|
||||||
wantedBy = ["multi-user.target"];
|
wantedBy = ["multi-user.target"];
|
||||||
path = lib.optional cfg.zfs pkgs.zfs;
|
path = lib.optional cfg.zfs pkgs.zfs;
|
||||||
|
environment = {
|
||||||
|
PORT = "${toString cfg.port}";
|
||||||
|
} // (if (cfg.mdns == false) then {
|
||||||
|
DISABLE_MDNS = "true";
|
||||||
|
} else {});
|
||||||
|
|
||||||
serviceConfig = let
|
serviceConfig = let
|
||||||
pkg = self.defaultPackage.${pkgs.system};
|
pkg = self.defaultPackage.${pkgs.system};
|
||||||
|
|
@ -110,7 +122,6 @@
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
ExecStart = "${pkg}/bin/palantir";
|
ExecStart = "${pkg}/bin/palantir";
|
||||||
User = "palantir";
|
User = "palantir";
|
||||||
Environment = "PORT=${toString cfg.port}";
|
|
||||||
PrivateTmp = true;
|
PrivateTmp = true;
|
||||||
ProtectSystem = "full";
|
ProtectSystem = "full";
|
||||||
ProtectHome = true;
|
ProtectHome = true;
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,8 @@ async fn main() -> Result<()> {
|
||||||
.transpose()?
|
.transpose()?
|
||||||
.unwrap_or(80);
|
.unwrap_or(80);
|
||||||
|
|
||||||
|
let mdns = dotenv::var("DISABLE_MDNS").is_ok();
|
||||||
|
|
||||||
ctrlc::set_handler(move || {
|
ctrlc::set_handler(move || {
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
})
|
})
|
||||||
|
|
@ -72,10 +74,12 @@ async fn main() -> Result<()> {
|
||||||
let docker = get_docker().await;
|
let docker = get_docker().await;
|
||||||
let docker = warp::any().map(move || docker.clone());
|
let docker = warp::any().map(move || docker.clone());
|
||||||
|
|
||||||
|
if !mdns {
|
||||||
spawn(setup_mdns(
|
spawn(setup_mdns(
|
||||||
hostname::get()?.into_string().unwrap(),
|
hostname::get()?.into_string().unwrap(),
|
||||||
host_port,
|
host_port,
|
||||||
));
|
));
|
||||||
|
}
|
||||||
|
|
||||||
let metrics = warp::path!("metrics").and(docker).and_then(serve_metrics);
|
let metrics = warp::path!("metrics").and(docker).and_then(serve_metrics);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue