have circus run static serve, and optionally able to skip services via Makefile
This commit is contained in:
parent
9343d2ea69
commit
6bebc3fae7
16
Makefile
16
Makefile
@ -1,8 +1,20 @@
|
|||||||
|
SKIP_SERVICES = []
|
||||||
|
|
||||||
all:
|
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:
|
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:
|
install.prod:
|
||||||
nix-build -A install --arg baseConfig '(import ./prod.config.nix)'
|
nix-build -A install --arg baseConfig '(import ./prod.config.nix)'
|
||||||
|
36
default.nix
36
default.nix
@ -7,6 +7,7 @@
|
|||||||
}) {},
|
}) {},
|
||||||
|
|
||||||
baseConfig ? import ./config.nix,
|
baseConfig ? import ./config.nix,
|
||||||
|
baseSkipServices ? [],
|
||||||
|
|
||||||
}: rec {
|
}: rec {
|
||||||
|
|
||||||
@ -14,6 +15,12 @@
|
|||||||
redisListenPath = "${config.runDir}/redis";
|
redisListenPath = "${config.runDir}/redis";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
skipServices = baseSkipServices ++ (
|
||||||
|
if baseConfig.staticProxyURL == ""
|
||||||
|
then [ "static" ]
|
||||||
|
else []
|
||||||
|
);
|
||||||
|
|
||||||
static = (import ./static) { inherit pkgs; };
|
static = (import ./static) { inherit pkgs; };
|
||||||
|
|
||||||
srv = (import ./srv) {
|
srv = (import ./srv) {
|
||||||
@ -38,18 +45,35 @@
|
|||||||
exec ${pkgs.redis}/bin/redis-server ${redisCfg}
|
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" ''
|
circusCfg = pkgs.writeText "mediocre-blog-circusCfg" ''
|
||||||
[circus]
|
[circus]
|
||||||
endpoint = tcp://127.0.0.1:0
|
endpoint = tcp://127.0.0.1:0
|
||||||
pubsub_endpoint = tcp://127.0.0.1:0
|
pubsub_endpoint = tcp://127.0.0.1:0
|
||||||
|
|
||||||
[watcher:srv]
|
${if (!builtins.elem "srv" skipServices) then srvCircusCfg else ""}
|
||||||
cmd = ${srv.bin}
|
|
||||||
numprocesses = 1
|
|
||||||
|
|
||||||
[watcher:redis]
|
${if (!builtins.elem "redis" skipServices) then redisCircusCfg else ""}
|
||||||
cmd = ${redisBin}
|
|
||||||
numprocesses = 1
|
${if (!builtins.elem "static" skipServices) then staticCircusCfg else ""}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
entrypoint = pkgs.writeScript "mediocre-blog-entrypoint" ''
|
entrypoint = pkgs.writeScript "mediocre-blog-entrypoint" ''
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
"-listen-proto=${config.listenProto}"
|
"-listen-proto=${config.listenProto}"
|
||||||
"-listen-addr=${config.listenAddr}"
|
"-listen-addr=${config.listenAddr}"
|
||||||
"-redis-proto=unix"
|
"-redis-proto=unix"
|
||||||
"-redis-addr=${config.runDir}/redis"
|
"-redis-addr=${config.redisListenPath}"
|
||||||
] ++ (
|
] ++ (
|
||||||
if config.staticProxyURL == ""
|
if config.staticProxyURL == ""
|
||||||
then [ "-static-dir=${staticBuild}" ]
|
then [ "-static-dir=${staticBuild}" ]
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
gemdir = ./.;
|
gemdir = ./.;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
build = pkgs.stdenv.mkDerivation {
|
build = pkgs.stdenv.mkDerivation {
|
||||||
name = "mediocre-blog-static";
|
name = "mediocre-blog-static";
|
||||||
src = ./src;
|
src = ./src;
|
||||||
|
Loading…
Reference in New Issue
Block a user