##
##  example.nomad -- Example Nomad Job Specification
##

job "example" {
    region = "global"
    datacenters = [ "dc1" ]
    type = "service"
    update {
        stagger = "10s"
        max_parallel = 1
    }
    group "cache" {
        count = 1
        restart {
            attempts = 10
            interval = "5m"
            delay = "25s"
            mode = "delay"
        }
        task "redis" {
            artifact {
                source = "http://repo.example.com/artifact.tar.gz"
                options {
                    checksum = "md5:00000000000000000000000000000000"
                }
            }
            driver = "raw_exec"
            config {
                command = "./start.sh"
                args = [ "10" ]
                port_map {
                    db = 6379
                }
            }
            service {
                name = "${TASKGROUP}-example"
                tags = [ "global", "cache" ]
                port = "example"
                check {
                    name = "alive"
                    type = "tcp"
                    interval = "10s"
                    timeout = "2s"
                }
            }
            env {
                NOMAD_DC="${node.datacenter}"
                NOMAD_NODE="${node.unique.name}"
                NOMAD_CPUS="${attr.cpu.numcores}"
            }
            resources {
                cpu = 500
                memory = 512
                network {
                    mbits = 10
                    port "example" {
                    }
                }
            }
            logs {
                max_files = 10
                max_file_size = 15
            }
            kill_timeout = "20s"
        }
    }
}

