have circus run static serve, and optionally able to skip services via Makefile

This commit is contained in:
Brian Picciano 2021-08-30 21:38:09 -06:00
parent 9343d2ea69
commit 6bebc3fae7
4 changed files with 45 additions and 10 deletions

View File

@ -1,8 +1,20 @@
SKIP_SERVICES = []
all:
nix-build -A entrypoint --arg baseConfig '(import ./config.nix) // { staticProxyURL = ""; }'
nix-build -A entrypoint \
--arg baseConfig '(import ./config.nix)' \
--arg baseSkipServices '${SKIP_SERVICES}'
run: all
./result
all.prod:
nix-build -A entrypoint --arg baseConfig '(import ./prod.config.nix)'
nix-build -A entrypoint \
--arg baseConfig '(import ./prod.config.nix)' \
--arg baseSkipServices '${SKIP_SERVICES}'
run.prod: all.prod
./result
install.prod:
nix-build -A install --arg baseConfig '(import ./prod.config.nix)'

View File

@ -7,6 +7,7 @@
}) {},
baseConfig ? import ./config.nix,
baseSkipServices ? [],
}: rec {
@ -14,6 +15,12 @@
redisListenPath = "${config.runDir}/redis";
};
skipServices = baseSkipServices ++ (
if baseConfig.staticProxyURL == ""
then [ "static" ]
else []
);
static = (import ./static) { inherit pkgs; };
srv = (import ./srv) {
@ -38,18 +45,35 @@
exec ${pkgs.redis}/bin/redis-server ${redisCfg}
'';
srvCircusCfg = ''
[watcher:srv]
cmd = ${srv.bin}
numprocesses = 1
'';
redisCircusCfg = ''
[watcher:redis]
cmd = ${redisBin}
numprocesses = 1
'';
staticCircusCfg = ''
[watcher:static]
cmd = ${static.serve}/bin/static-serve
numprocesses = 1
working_dir = ./static
'';
circusCfg = pkgs.writeText "mediocre-blog-circusCfg" ''
[circus]
endpoint = tcp://127.0.0.1:0
pubsub_endpoint = tcp://127.0.0.1:0
[watcher:srv]
cmd = ${srv.bin}
numprocesses = 1
${if (!builtins.elem "srv" skipServices) then srvCircusCfg else ""}
[watcher:redis]
cmd = ${redisBin}
numprocesses = 1
${if (!builtins.elem "redis" skipServices) then redisCircusCfg else ""}
${if (!builtins.elem "static" skipServices) then staticCircusCfg else ""}
'';
entrypoint = pkgs.writeScript "mediocre-blog-entrypoint" ''

View File

@ -12,7 +12,7 @@
"-listen-proto=${config.listenProto}"
"-listen-addr=${config.listenAddr}"
"-redis-proto=unix"
"-redis-addr=${config.runDir}/redis"
"-redis-addr=${config.redisListenPath}"
] ++ (
if config.staticProxyURL == ""
then [ "-static-dir=${staticBuild}" ]

View File

@ -13,7 +13,6 @@
gemdir = ./.;
};
build = pkgs.stdenv.mkDerivation {
name = "mediocre-blog-static";
src = ./src;