Skip to content

Commit

Permalink
services/nomad/apps/popcorn-report.nomad: add nomad job
Browse files Browse the repository at this point in the history
this component of popcorn reads what statrepo has collected and dumps it
to json every night. these json dumps are used by pqueryd and served by nginx.
  • Loading branch information
classabbyamp committed Jul 4, 2024
1 parent 3a1f4c6 commit dca3159
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions services/nomad/apps/popcorn-report.nomad
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
job "popcorn-report" {
datacenters = ["VOID-MIRROR"]
namespace = "apps"
type = "batch"

periodic {
crons = ["@daily"]
prohibit_overlap = true
}

group "report" {
count = 1

network { mode = "bridge" }

volume "popcorn_data" {
type = "host"
source = "popcorn_data"
read_only = false
}

task "report" {
driver = "docker"

config {
image = "ghcr.io/void-linux/infra-popcorn:20240704R1"
command = "/local/popcorn-report"
}

volume_mount {
volume = "popcorn_data"
destination = "/data"
}

env {
OUTDIR = "/data"
}

template {
data = <<EOF
#!/bin/sh
{{ range service "popcorn-statrepo" }}
exec popcornctl --server "{{ .Address }}" --port "{{ .Port }}" \
report --reset --key "${POPCORN_KEY}" --file "${OUTDIR}/popcorn_$(date +%F).json"
{{ end }}
EOF
destination = "local/popcorn-report"
perms = "755"
}

template {
data = <<EOF
{{- with nomadVar "nomad/jobs/popcorn" -}}
POPCORN_KEY={{.reset_key}}
{{- end -}}
EOF
destination = "secrets/env"
env = true
}
}
}
}

0 comments on commit dca3159

Please sign in to comment.