live.nomad 1.93 KB
Newer Older
1
2
# This should best be equal to project name, and also the binary name without extension. This defines the ${NOMAD_JOB_NAME}
job "pdf-generator" {
Uta Christoph's avatar
Uta Christoph committed
3
  datacenters = ["rwth-app-testing"]
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  type = "system"

  update {
    stagger      = "60s"
    max_parallel = 1
  }

  # Should probably be equal to the Job Name in most cases. This defines the ${NOMAD_GROUP_NAME}
  group "pdf-generator" {

    # Should probably be equal to the Job/Group Name in most cases. This defines the ${NOMAD_TASK_NAME}
    task "pdf-generator" {

      driver = "raw_exec"

      config {
        command = "dotnet"

        # This needs to point to the binary, and config file, relative or absolute.
        # Currently raw_exec will execute everything directly from the created alloc dir ${NOMAD_ALLOC_DIR},
        # but the content will be placed in the /local subdirectory {$NOMAD_TASK_DIR}
        args = [
          "local/pdf-generator.dll",
          "local/appsettings.json"
        ]
      }

      env{
        # Use all IP addresses and port set by Nomad
        ASPNETCORE_URLS = "http://*:${NOMAD_PORT_http}",

        # Pass the basedir used by Traefik to the app
36
        ASPNETCORE_BASEPATH = "/internal/${NOMAD_TASK_NAME}"
37
38
39
40
41
42
43
      }

      service {
        name = "${NOMAD_TASK_NAME}"
        port = "http"
        tags = [
          "traefik.enable=true",
44
          "traefik.Path=/internal/${NOMAD_TASK_NAME}"
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
        ]

        # The check URL needs to answer with status 200, preferbly use something like a version API call
        check {
          type     = "http"
          path     = "/swagger/index.html"
          interval = "10s"
          timeout  = "2s"
        }
      }

      resources {
        network {
          # This way Nomad will designate a single, random, port named http to the service
          port "http" { }
        }
      }

      artifact {
        # This will be filled by the Gitlab runner script
        source = "{{ artifact_url }}"
      }
    }
  }
Uta Christoph's avatar
Uta Christoph committed
69
}