Skip to content

Commit

Permalink
Create test_include_mysql variable (#286)
Browse files Browse the repository at this point in the history
  • Loading branch information
lens0021 authored Oct 6, 2024
1 parent 08a5b2d commit 55f64e8
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions jobs/fastcgi.nomad
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ variable "mysql_password_mediawiki" {
default = ""
}

variable "test_include_mysql" {
type = bool
description = "Whether connect to the MySQL in the same Nomad cluster. Only effective when `test` is true"
default = false
}

locals {
main = !var.test
}
Expand Down Expand Up @@ -62,8 +68,8 @@ job "fastcgi" {
network_mode = "host"
args = [
"-c",
true ? "echo -n 'Waiting for service'; until nc -z ${var.main_nomad_addr} 3306 < /dev/null; do echo '.'; sleep 2; done"
: "echo -n 'Waiting for service'; until nslookup mysql.service.consul 127.0.0.1:8600 2>&1 >/dev/null; do echo '.'; sleep 2; done",
var.test_include_mysql ? "echo -n 'Waiting for service'; until nslookup mysql.service.consul 127.0.0.1:8600 2>&1 >/dev/null; do echo '.'; sleep 2; done"
: "echo -n 'Waiting for service'; until nc -z ${var.main_nomad_addr} 3306 < /dev/null; do echo '.'; sleep 2; done",
]
}

Expand Down Expand Up @@ -256,9 +262,13 @@ job "fastcgi" {
connect {
sidecar_service {
proxy {
upstreams {
destination_name = "mysql"
local_bind_port = 3306

dynamic "upstreams" {
for_each = test_include_mysql ? [{}] : []
content {
destination_name = "mysql"
local_bind_port = 3306
}
}

upstreams {
Expand Down

0 comments on commit 55f64e8

Please sign in to comment.