Skip to content

Commit

Permalink
nomad updates
Browse files Browse the repository at this point in the history
  • Loading branch information
allthingsclowd committed Sep 23, 2018
1 parent 48c8833 commit ac0a211
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 7 deletions.
2 changes: 1 addition & 1 deletion conf/nginx.ctpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
upstream goapp {
{{range services}}{{if .Name | regexMatch "goapp*"}}{{range service .Name}}
{{range services}}{{if .Name | regexMatch "webpagecounter*"}}{{range service .Name}}
server {{.Address}}:{{.Port}} max_fails=3 fail_timeout=60 weight=1; {{end}}{{end}}
{{else}}server 127.0.0.1:65535; # force a 502{{end}}
}
Expand Down
62 changes: 56 additions & 6 deletions nomad_job.hcl
Original file line number Diff line number Diff line change
@@ -1,9 +1,59 @@
job "webpagecounter" {
datacenters = ["dc1"]
type = "service"
group "webcountergroup" {
count = 4
task "deploy-webcounters" {



group "webcountergroup-a" {
constraint {
distinct_hosts = true
}
count = 2
task "deploy-webcounters-a" {
driver = "raw_exec"
config {
command = "/usr/local/bin/webcounter"
args = ["-port=${NOMAD_PORT_http}", "-ip=0.0.0.0","-templates=/usr/local/bin/templates/*.html"]
}
resources {
cpu = 20
memory = 60
network {
port "http" {}
}
}


service {
name = "webpagecounter"
port = "http"
check {
name = "health-check-webpagecounter-${NOMAD_PORT_http}"
type = "http"
path = "/health"
interval = "10s"
timeout = "2s"
}
check {
type = "script"
name = "scripted-check-webpagecounter-${NOMAD_PORT_http}"
command = "/usr/local/bin/consul_goapp_verify.sh"
args = ["http://127.0.0.1:${NOMAD_PORT_http}/health"]
interval = "60s"
timeout = "5s"

check_restart {
limit = 3
grace = "90s"
ignore_warnings = false
}
}
}
}
}
group "webcountergroup-b" {
count = 3
task "deploy-webcounters-b" {
driver = "raw_exec"
config {
command = "/usr/local/bin/webcounter"
Expand All @@ -19,18 +69,18 @@ job "webpagecounter" {


service {
name = "goapp-${NOMAD_PORT_http}"
name = "webpagecounter"
port = "http"
check {
name = "http-check-goapp-${NOMAD_PORT_http}"
name = "health-check-webpagecounter-${NOMAD_PORT_http}"
type = "http"
path = "/health"
interval = "10s"
timeout = "2s"
}
check {
type = "script"
name = "api-check-goapp-${NOMAD_PORT_http}"
name = "scripted-check-webpagecounter-${NOMAD_PORT_http}"
command = "/usr/local/bin/consul_goapp_verify.sh"
args = ["http://127.0.0.1:${NOMAD_PORT_http}/health"]
interval = "60s"
Expand Down

0 comments on commit ac0a211

Please sign in to comment.