discourse_docker/templates
Jeff Wong 136aefe49d
Move DB initialization scripts for postgres and redis into service files.
This resolves a race condition with unconfigured images attempting to bring up
DBs for the first time. This does not affect fully bootstrapped images.

Currently, all jobs start at boot - this includes postgres.

Issue with the current is - postgres starts and adds the corresponding .s/.pid
files to /var/run/postgres.

Simultaneously, the unicorn job gets started, checks to see if postgres is
running (it is already at this point from boot), and runs install_postgres.

Inside the install_postgres script, we mount the shared postgres folder and
remove .s/.pid files -- after postgres has already been started. In this case,
we remove the (in-use) .s and .pid files.

Subsequent unicorn tasks fail, erroring out the service and forcing it into
a restart loop. Since postgres never restarts, it never regenerates the .s/.pid
files, and unicorn can never run successfully.

This proposal moves install_postgres into the postgres job file, eliminating the
race condition. Since they are part of the same service, install_postgres will
always run before starting postgres - it will no longer be able to remove valid
.s and .pid files.

Redis has a similar race condition with the creation of its data folder. This
isn't as disastrous as the redis service restarts until the folder exists from
unicorn run, but it provides better reasoning about the running services.

Add early exit from unicorn boot scripts to properly retry migrate as well.

Use pg_isready to check if pg is ready directly in create_db.
Merge the ready check into create_db.

Run create_db in a subshell on postgres job start, rather than in unicorn script.

remove postgres-config call
2025-05-19 10:18:07 -07:00
..
import Removing unicorn service from phpbb template broke the build (#934) 2025-02-27 11:24:26 -05:00
README.md Create README.md 2015-10-16 05:42:12 -07:00
cache-dns.template.yml FEATURE: added template for critical DNS caching 2018-11-23 15:09:11 +11:00
cloudflare.template.yml DEV: Make wget consistently quiet (#612) 2022-03-15 10:43:10 +01:00
cron.template.yml - Update base image 2014-08-20 13:17:08 +10:00
enable-ruby-yjit.yml DEV: Introduce `enable-ruby-yjit template 2023-05-01 10:32:34 +07:00
fastly.template.yml it should be global 2015-05-12 15:12:24 +10:00
offline-page.template.yml Revert "Use Nginx config with outlets (#913)" (#958) 2025-05-09 11:09:35 +08:00
postgres.9.5.template.yml FEATURE: Update base image and set default to postgresql 15 (#909) 2025-01-29 10:20:49 +03:00
postgres.10.template.yml FEATURE: Update base image and set default to postgresql 15 (#909) 2025-01-29 10:20:49 +03:00
postgres.12.template.yml FEATURE: Update base image and set default to postgresql 15 (#909) 2025-01-29 10:20:49 +03:00
postgres.13.template.yml FEATURE: Update base image and set default to postgresql 15 (#909) 2025-01-29 10:20:49 +03:00
postgres.15.template.yml FIX: install pgvector package for old PG versions during update (#932) 2025-01-29 18:32:39 +03:00
postgres.template.yml Move DB initialization scripts for postgres and redis into service files. 2025-05-19 10:18:07 -07:00
redis.template.yml Move DB initialization scripts for postgres and redis into service files. 2025-05-19 10:18:07 -07:00
sshd.template.yml Revert "Use Nginx config with outlets (#913)" (#958) 2025-05-09 11:09:35 +08:00
syslog.template.yml - Update base image 2014-08-20 13:17:08 +10:00
web.china.template.yml Update Discourse installation support in China (pnpm) (#867) 2024-09-06 17:10:52 +01:00
web.ipv6.template.yml Revert "Use Nginx config with outlets (#913)" (#958) 2025-05-09 11:09:35 +08:00
web.letsencrypt.ssl.template.yml Revert "Use Nginx config with outlets (#913)" (#958) 2025-05-09 11:09:35 +08:00
web.onion.template.yml Template for serving through an .onion address. 2016-03-24 21:48:04 +01:00
web.ratelimited.template.yml Revert "Use Nginx config with outlets (#913)" (#958) 2025-05-09 11:09:35 +08:00
web.socketed.template.yml Revert "Use Nginx config with outlets (#913)" (#958) 2025-05-09 11:09:35 +08:00
web.ssl.template.yml Revert "Use Nginx config with outlets (#913)" (#958) 2025-05-09 11:09:35 +08:00
web.template.yml Move DB initialization scripts for postgres and redis into service files. 2025-05-19 10:18:07 -07:00

README.md

pups-managed templates you may use to bootstrap your environment.