File tree 3 files changed +103
-10
lines changed
3 files changed +103
-10
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,10 @@ job "apiary" {
75
75
type = " service"
76
76
77
77
group "apiary" {
78
+ network {
79
+ port "resp" {}
80
+ }
81
+
78
82
volume "run" {
79
83
type = " host"
80
84
source = " run"
378
382
}
379
383
}
380
384
}
385
+
386
+ dynamic "task" {
387
+ for_each = var. run_background_containers ? [" redis" ] : []
388
+
389
+ labels = [task . value ]
390
+
391
+ content {
392
+ driver = " docker"
393
+
394
+ lifecycle {
395
+ hook = " prestart"
396
+ sidecar = true
397
+ }
398
+
399
+ config {
400
+ image = " redis"
401
+
402
+ args = [
403
+ " /usr/local/etc/redis/redis.conf"
404
+ ]
405
+
406
+ force_pull = true
407
+
408
+ network_mode = " host"
409
+
410
+ mount {
411
+ type = " bind"
412
+ source = " secrets/"
413
+ target = " /usr/local/etc/redis/"
414
+ }
415
+ }
416
+
417
+ resources {
418
+ cpu = 100
419
+ memory = 256
420
+ memory_max = 2048
421
+ }
422
+
423
+ template {
424
+ data = << EOH
425
+ bind 127.0.0.1
426
+ port {{ env "NOMAD_PORT_resp" }}
427
+ unixsocket /alloc/tmp/redis.sock
428
+ unixsocketperm 777
429
+ requirepass {{ env "NOMAD_ALLOC_ID" }}
430
+ maxmemory {{ env "NOMAD_MEMORY_MAX_LIMIT" }}mb
431
+ maxmemory-policy allkeys-lru
432
+ EOH
433
+
434
+ destination = " secrets/redis.conf"
435
+ }
436
+
437
+ service {
438
+ name = " ${ NOMAD_JOB_NAME } -redis"
439
+
440
+ port = " resp"
441
+
442
+ address = " 127.0.0.1"
443
+
444
+ tags = [
445
+ " resp"
446
+ ]
447
+
448
+ check {
449
+ success_before_passing = 3
450
+ failures_before_critical = 2
451
+
452
+ interval = " 5s"
453
+
454
+ name = " TCP"
455
+ port = " resp"
456
+ timeout = " 1s"
457
+ type = " tcp"
458
+ }
459
+
460
+ check_restart {
461
+ limit = 5
462
+ grace = " 20s"
463
+ }
464
+ }
465
+
466
+ restart {
467
+ attempts = 5
468
+ delay = " 10s"
469
+ interval = " 1m"
470
+ mode = " fail"
471
+ }
472
+
473
+ shutdown_delay = " 60s"
474
+ }
475
+ }
381
476
}
382
477
383
478
reschedule {
Original file line number Diff line number Diff line change @@ -11,13 +11,6 @@ CAS_ENABLE_SAML="false"
11
11
{ {- range service " mysql" } }
12
12
DB_SOCKET="{ {- index .ServiceMeta " socket" | trimSpace -} }"
13
13
{ { end } }
14
- REDIS_CLIENT="phpredis"
15
- REDIS_SCHEME="null"
16
- REDIS_PORT="-1"
17
- { {- range service " redis" } }
18
- REDIS_HOST="{ {- index .ServiceMeta " socket" | trimSpace -} }"
19
- { { end } }
20
- REDIS_PASSWORD="{ {- key " redis/password" | trimSpace -} }"
21
14
{ {- range service " meilisearch-v1-10" } }
22
15
MEILISEARCH_HOST="http://127.0.0.1:{ {- .Port -} }"
23
16
{ { end } }
@@ -36,3 +29,10 @@ HOME="/secrets/"
36
29
RESPONSE_CACHE_HEADER_NAME="x-cache-time"
37
30
RESPONSE_CACHE_AGE_HEADER_NAME="x-cache-age"
38
31
RESPONSE_CACHE_AGE_HEADER=true
32
+ REDIS_CLIENT="phpredis"
33
+ REDIS_SCHEME="null"
34
+ REDIS_PORT="-1"
35
+ REDIS_HOST="/alloc/tmp/redis.sock"
36
+ REDIS_PASSWORD="{ { env " NOMAD_ALLOC_ID" } }"
37
+ REDIS_DB=0
38
+ REDIS_CACHE_DB=1
Original file line number Diff line number Diff line change @@ -13,9 +13,7 @@ catch_workers_output = yes
13
13
php_admin_value[date.timezone] = America/New_York
14
14
{{ if ne (env "NOMAD_JOB_NAME") "apiary-sandbox" }}
15
15
php_admin_value[session.save_handler] = redis
16
- {{- range service "redis" }}
17
- php_admin_value[session.save_path] = "unix://{{- index .ServiceMeta "socket" | trimSpace -}}?persistent=1&database={{- with (key "redis/session_database" | parseJSON) -}}{{- index . (env "NOMAD_JOB_NAME") -}}{{- end -}}&timeout=1&auth={{- key "redis/password" | trimSpace -}}"
18
- {{ end }}
16
+ php_admin_value[session.save_path] = "unix:///alloc/tmp/redis.sock?persistent=1&database=2&timeout=1&auth={{ env "NOMAD_ALLOC_ID" }}"
19
17
{{ end }}
20
18
access.log = /proc/self/fd/2
21
19
access.format = "%t %m %{REQUEST_URI}e %s %f %{mili}d %{kilo}M %C \"%{HTTP_USER_AGENT}e\"%"
You can’t perform that action at this time.
0 commit comments