forked from DGNum/liminix
add service name to log lines
This commit is contained in:
parent
5427456c21
commit
a8cb872859
4 changed files with 50 additions and 18 deletions
10
overlay.nix
10
overlay.nix
|
@ -4,6 +4,16 @@ in
|
||||||
extraPkgs // {
|
extraPkgs // {
|
||||||
strace = prev.strace.override { libunwind = null; };
|
strace = prev.strace.override { libunwind = null; };
|
||||||
|
|
||||||
|
s6 = prev.s6.overrideAttrs(o: {
|
||||||
|
patches =
|
||||||
|
(if o ? patches then o.patches else []) ++ [
|
||||||
|
(final.fetchpatch {
|
||||||
|
# add "p" directive in s6-log
|
||||||
|
url = "https://github.com/skarnet/s6/commit/ddc76841398dfd5e18b22943727ad74b880236d3.patch";
|
||||||
|
hash = "sha256-fBtUinBdp5GqoxgF6fcR44Tu8hakxs/rOShhuZOgokc=";
|
||||||
|
})];
|
||||||
|
});
|
||||||
|
|
||||||
dnsmasq =
|
dnsmasq =
|
||||||
let d = prev.dnsmasq.overrideAttrs(o: {
|
let d = prev.dnsmasq.overrideAttrs(o: {
|
||||||
preBuild = ''
|
preBuild = ''
|
||||||
|
|
|
@ -10,10 +10,11 @@ test -n "$contents" && for d in $contents; do
|
||||||
mkdir -p $out/${name}/contents.d
|
mkdir -p $out/${name}/contents.d
|
||||||
touch $out/${name}/contents.d/$d
|
touch $out/${name}/contents.d/$d
|
||||||
done
|
done
|
||||||
test -n "$run" && (echo -e "$run" > $out/${name}/run)
|
|
||||||
test -n "${notification-fd}" && (echo ${notification-fd} > $out/${name}/notification-fd)
|
for i in run notification-fd up down consumer-for producer-for pipeline-name ; do
|
||||||
test -n "$up" && (echo -e "$up" > $out/${name}/up)
|
test -n "$(printenv $i)" && (echo "$(printenv $i)" > $out/${name}/$i)
|
||||||
test -n "$down" && (echo -e "$down" > $out/${name}/down)
|
done
|
||||||
|
|
||||||
( cd $out && ln -s /run/service-state/${name} ./.outputs )
|
( cd $out && ln -s /run/service-state/${name} ./.outputs )
|
||||||
for i in $out/${name}/{down,up,run} ; do test -f $i && chmod +x $i; done
|
for i in $out/${name}/{down,up,run} ; do test -f $i && chmod +x $i; done
|
||||||
true
|
true
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
stdenvNoCC
|
stdenvNoCC
|
||||||
, s6-rc
|
, s6-rc
|
||||||
|
, s6
|
||||||
, lib
|
, lib
|
||||||
, busybox
|
, busybox
|
||||||
, callPackage
|
, callPackage
|
||||||
|
@ -12,6 +13,7 @@ let
|
||||||
output = service: name: "/run/service-state/${service.name}/${name}";
|
output = service: name: "/run/service-state/${service.name}/${name}";
|
||||||
serviceScript = commands : ''
|
serviceScript = commands : ''
|
||||||
#!${busybox}/bin/sh
|
#!${busybox}/bin/sh
|
||||||
|
exec 2>&1
|
||||||
. ${serviceFns}
|
. ${serviceFns}
|
||||||
${commands}
|
${commands}
|
||||||
'';
|
'';
|
||||||
|
@ -23,17 +25,23 @@ let
|
||||||
, down ? null
|
, down ? null
|
||||||
, outputs ? []
|
, outputs ? []
|
||||||
, notification-fd ? null
|
, notification-fd ? null
|
||||||
|
, producer-for ? null
|
||||||
|
, consumer-for ? null
|
||||||
|
, pipeline-name ? null
|
||||||
, dependencies ? []
|
, dependencies ? []
|
||||||
, contents ? []
|
, contents ? []
|
||||||
} @ args: stdenvNoCC.mkDerivation {
|
, buildInputs ? []
|
||||||
# we use stdenvNoCC to avoid generating derivations with names
|
} @ args:
|
||||||
# like foo.service-mips-linux-musl
|
stdenvNoCC.mkDerivation {
|
||||||
inherit name serviceType up down run notification-fd;
|
# we use stdenvNoCC to avoid generating derivations with names
|
||||||
buildInputs = dependencies ++ contents;
|
# like foo.service-mips-linux-musl
|
||||||
dependencies = builtins.map (d: d.name) dependencies;
|
inherit name serviceType up down run notification-fd
|
||||||
contents = builtins.map (d: d.name) contents;
|
producer-for consumer-for pipeline-name;
|
||||||
builder = ./builder.sh;
|
buildInputs = buildInputs ++ dependencies ++ contents;
|
||||||
};
|
dependencies = builtins.map (d: d.name) dependencies;
|
||||||
|
contents = builtins.map (d: d.name) contents;
|
||||||
|
builder = ./builder.sh;
|
||||||
|
};
|
||||||
|
|
||||||
longrun = {
|
longrun = {
|
||||||
name
|
name
|
||||||
|
@ -41,10 +49,23 @@ let
|
||||||
, outputs ? []
|
, outputs ? []
|
||||||
, notification-fd ? null
|
, notification-fd ? null
|
||||||
, dependencies ? []
|
, dependencies ? []
|
||||||
} @ args: service (args //{
|
, ...
|
||||||
serviceType = "longrun";
|
} @ args:
|
||||||
run = serviceScript run;
|
let logger = service {
|
||||||
});
|
serviceType = "longrun";
|
||||||
|
name = "${name}-log";
|
||||||
|
run = serviceScript "${s6}/bin/s6-log -d 10 -- p${name} 1";
|
||||||
|
notification-fd = 10;
|
||||||
|
consumer-for = name;
|
||||||
|
pipeline-name = "${name}-pipeline";
|
||||||
|
};
|
||||||
|
in service (args // {
|
||||||
|
buildInputs = [ logger ];
|
||||||
|
serviceType = "longrun";
|
||||||
|
run = serviceScript run;
|
||||||
|
producer-for = "${name}-log";
|
||||||
|
});
|
||||||
|
|
||||||
oneshot = {
|
oneshot = {
|
||||||
name
|
name
|
||||||
, up
|
, up
|
||||||
|
|
|
@ -43,7 +43,7 @@ in rec {
|
||||||
imports = [
|
imports = [
|
||||||
./modules/wlan.nix
|
./modules/wlan.nix
|
||||||
./modules/tftpboot.nix
|
./modules/tftpboot.nix
|
||||||
./modules/flashable.nix
|
# ./modules/flashable.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
kernel = {
|
kernel = {
|
||||||
|
|
Loading…
Reference in a new issue