job "asapo-receivers" {
  datacenters = ["dc1"]

  update {
    max_parallel = 1
    min_healthy_time = "10s"
    healthy_deadline = "3m"
    auto_revert = false
  }

  group "receivers" {
    count = 1

    restart {
      attempts = 2
      interval = "3m"
      delay = "15s"
      mode = "fail"
    }

    task "receivers" {
      driver = "docker"

      config {
        network_mode = "host"
        dns_servers = ["127.0.0.1"]
        image = "yakser/asapo-receiver:feature_ha"
	    force_pull = true
        volumes = ["local/config.json:/var/lib/receiver/config.json",
                   "/bldocuments/support/asapo/data:/var/lib/receiver/data"]
        logging {
            type = "fluentd"
            config {
                fluentd-address = "localhost:9881"
                tag = "asapo.docker"
            }
        }
      }

      resources {
        network {
          port "recv" {}
        }
      }

      service {
        port = "recv"
        name = "asapo-receiver"
        check {
          name     = "asapo-receiver-alive"
          type     = "tcp"
          interval = "10s"
          timeout  = "2s"
        }
        check_restart {
          limit = 2
          grace = "15s"
          ignore_warnings = false
        }
      }

      template {
         source        = "@NOMAD_INSTALL@/receiver.json.tpl"
         destination   = "local/config.json"
         change_mode   = "restart"
      }
   }
  }
}

