Add more conditional checks to Blocky so it is more resiliant
Hopefully this will allow it to deploy if mysql or vault are down
This commit is contained in:
parent
f8555f0900
commit
3a95fb46db
@ -150,7 +150,7 @@ job "blocky" {
|
||||
args = [
|
||||
"/bin/bash",
|
||||
"-c",
|
||||
"/usr/bin/mysql --defaults-extra-file=$${NOMAD_SECRETS_DIR}/my.cnf < $${NOMAD_SECRETS_DIR}/bootstrap.sql",
|
||||
"/usr/bin/mysql --defaults-extra-file=$${NOMAD_SECRETS_DIR}/my.cnf < $${NOMAD_SECRETS_DIR}/bootstrap.sql || echo 'SQL Failed'",
|
||||
]
|
||||
}
|
||||
|
||||
@ -167,16 +167,16 @@ job "blocky" {
|
||||
host={{ env "NOMAD_UPSTREAM_IP_mysql_server" }}
|
||||
port={{ env "NOMAD_UPSTREAM_PORT_mysql_server" }}
|
||||
user=root
|
||||
{{ with secret "kv/data/mysql" }}
|
||||
{{ with service "vault" -}}{{ with secret "kv/data/mysql" }}
|
||||
password={{ .Data.data.root_password }}
|
||||
{{ end }}
|
||||
{{ end -}}{{ end -}}
|
||||
EOF
|
||||
destination = "$${NOMAD_SECRETS_DIR}/my.cnf"
|
||||
}
|
||||
|
||||
template {
|
||||
data = <<EOF
|
||||
{{ with secret "kv/data/blocky" -}}
|
||||
{{ with service "vault" -}}{{ with secret "kv/data/blocky" -}}
|
||||
{{ if .Data.data.db_name -}}
|
||||
{{ $db_name := .Data.data.db_name }}
|
||||
CREATE DATABASE IF NOT EXISTS `{{ $db_name }}`;
|
||||
@ -190,7 +190,7 @@ GRANT SELECT ON `{{ $db_name }}`.* to '{{ .Data.data.db_user_ro }}'@'%';
|
||||
{{ else -}}
|
||||
SELECT 'NOOP';
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
{{ end -}}{{ end -}}
|
||||
EOF
|
||||
destination = "$${NOMAD_SECRETS_DIR}/bootstrap.sql"
|
||||
}
|
||||
|
@ -104,7 +104,8 @@ queryLog:
|
||||
type: mysql
|
||||
target: {{ .Data.data.db_user }}:{{ .Data.data.db_pass }}@tcp({{ env "NOMAD_UPSTREAM_ADDR_mysql_server" }})/{{ .Data.data.db_name }}?charset=utf8mb4&parseTime=True&loc=Local
|
||||
logRetentionDays: 14
|
||||
{{ end -}}{{ end -}}{{ end -}}
|
||||
{{ end -}}
|
||||
{{ end -}}{{ end -}}
|
||||
|
||||
port: 53
|
||||
httpPort: 4000
|
||||
|
Loading…
Reference in New Issue
Block a user