job "broker" {
  datacenters = ["dc1"]

  type = "service"

  group "group" {
    count = 1

    task "broker" {
      driver = "raw_exec"

      config {
        command = "@BROKER_FULLPATH@"
        args =  ["-config","${NOMAD_TASK_DIR}/broker.json"]
      }

      resources {
        cpu    = 50 # 50 MHz
        memory = 256 # 256MB
        network {
          port "broker" {
          }
        }
      }

      service {
        name = "asapo-broker"
        port = "broker"
        check {
          name     = "alive"
          type     = "http"
          path     = "/health"
          interval = "10s"
          timeout  = "2s"
          initial_status =   "passing"
        }
      }

      template {
         source        = "@WORK_DIR@/broker.json.tpl"
         destination   = "local/broker.json"
         change_mode   = "signal"
         change_signal = "SIGHUP"
      }

      template {
         source        = "@WORK_DIR@/auth_secret.key"
         destination   = "auth_secret.key"
         change_mode   = "signal"
         change_signal = "SIGHUP"
      }
    }
  }
}
