Skip to content

Commit

Permalink
rename service with 's-' prefix, add job for portfolio stats
Browse files Browse the repository at this point in the history
  • Loading branch information
cottand committed Aug 10, 2024
1 parent addac42 commit 73d9532
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 5 deletions.
2 changes: 1 addition & 1 deletion services/default.nix
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{ callPackage, writeText, ... }: {
portfolio-stats = callPackage (import ./portfolio-stats) { };
s-portfolio-stats = callPackage (import ./s-portfolio-stats) { };
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
{ buildGoModule, dockerTools, bash, buildEnv, writeShellScriptBin, ... }:
let
name = "portfolio-stats";
name = "s-portfolio-stats";
bin = buildGoModule ({
inherit name;
src = ../.;
subPackages = [ name ];
vendorHash = null;
});
start = writeShellScriptBin "start" "${bin}/bin/${name}";
image = dockerTools.buildImage {
name = "portfolio-stats";
tag = "latest";
inherit name;
copyToRoot = buildEnv {
inherit name;
paths = [ bash bin ];
Expand Down
83 changes: 83 additions & 0 deletions services/s-portfolio-stats/job.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
let
lib = import ../../jobs/lib;
version = "c865dfa";
name = "s-portfolio-stats";
cpu = 120;
mem = 500;
ports = {
http = 8888;
upDb = 5432;
upS3 = 3333;
};
sidecarResources = with builtins; mapAttrs (_: ceil) {
cpu = 0.20 * cpu;
memoryMB = 0.25 * mem;
memoryMaxMB = 0.25 * mem + 100;
};
otlpPort = 9001;
bind = lib.localhost;
in
lib.mkJob name {
update = {
maxParallel = 1;
autoRevert = true;
autoPromote = true;
canary = 1;
};

group.${name} = {
count = 1;
network = {
mode = "bridge";
dynamicPorts = [
{ label = "health"; }
];
reservedPorts = [
];
};

service.${name} = {
connect.sidecarService = {
proxy = {
upstream."tempo-otlp-grpc-mesh".localBindPort = otlpPort;

config = lib.mkEnvoyProxyConfig {
otlpService = "proxy-${name}";
otlpUpstreamPort = otlpPort;
protocol = "http";
};
};
};
connect.sidecarTask.resources = sidecarResources;
# TODO implement http healthcheck
port = toString ports.http;
# tags = [
# "traefik.enable=true"
# "traefik.consulcatalog.connect=true"
# "traefik.http.routers.\${NOMAD_GROUP_NAME}-http.entrypoints=web,websecure"
# "traefik.http.routers.\${NOMAD_GROUP_NAME}-http.tls=true"
# "traefik.http.routers.\${NOMAD_GROUP_NAME}-http.middlewares=mesh-whitelist@file"
# ];
};
task.${name} = {
driver = "docker";
vault = { };

config = {
image = "ghcr.io/cottand/selfhosted/${name}:${version}";
# ports = ["http" "grpc", "metrics", "webdav"];
# args = [
# "--config"
# "/local/config.toml"
# "--listen"
# "${bind}:${toString ports.http}"
# ];
};
resources = {
cpu = cpu;
memoryMb = mem;
memoryMaxMb = builtins.ceil (2 * mem);
};
};
};
}
File renamed without changes.

0 comments on commit 73d9532

Please sign in to comment.