Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions templates/postgres.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ hooks:
filename: /etc/service/unicorn/run
from: "# postgres"
to: |
if [ -f /root/install_postgres ]; then
/root/install_postgres
rm /root/install_postgres
fi
sv start postgres || exit 1

run:
Expand All @@ -29,6 +25,15 @@ run:
contents: |
#!/bin/sh
exec 2>&1
if [ -f /root/install_postgres ]; then
/root/install_postgres
rm /root/install_postgres
fi
if [ "$CREATE_DB_ON_BOOT" = "1" ]; then
sudo -E -u postgres /usr/lib/postgresql/15/bin/pg_ctl -D /etc/postgresql/15/main -o "-c listen_addresses='' -p 5432" -w start
/usr/local/bin/create_db
sudo -E -u postgres /usr/lib/postgresql/15/bin/pg_ctl -D /etc/postgresql/15/main -m fast -w stop
fi
HOME=/var/lib/postgresql USER=postgres exec thpoff chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/15/bin/postmaster -D /etc/postgresql/15/main

- file:
Expand Down Expand Up @@ -258,6 +263,9 @@ run:
su postgres -c 'psql $db_name -c "create extension if not exists vector;"'
su postgres -c 'psql $db_name -c "alter extension vector update;"' || true
sudo -u postgres psql $db_name <<< "update pg_database set encoding = pg_char_to_encoding('UTF8') where datname = '$db_name' AND encoding = pg_char_to_encoding('SQL_ASCII');" || true
if [ ! -z "$DISCOURSE_DB_PASSWORD" ]; then
echo "alter user $db_user with password '$DISCOURSE_DB_PASSWORD';" | su - postgres -c 'psql $db_name'
fi

- file:
path: /var/lib/postgresql/take-database-backup
Expand Down
4 changes: 1 addition & 3 deletions templates/redis.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ run:
contents: |
#!/bin/sh
exec 2>&1
install -d -m 0755 -o redis -g redis /shared/redis_data
exec thpoff chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf
- file:
path: /etc/service/redis/log/run
Expand Down Expand Up @@ -88,7 +89,4 @@ hooks:
filename: /etc/service/unicorn/run
from: "# redis"
to: |
if [ ! -d /shared/redis_data ]; then
install -d -m 0755 -o redis -g redis /shared/redis_data
fi
sv start redis || exit 1
9 changes: 6 additions & 3 deletions templates/web.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@ run:
if [[ -z "$PRECOMPILE_ON_BOOT" ]]; then
PRECOMPILE_ON_BOOT=1
fi
if [ -f /usr/local/bin/create_db ] && [ "$CREATE_DB_ON_BOOT" = "1" ]; then /usr/local/bin/create_db; fi;
if [ "$MIGRATE_ON_BOOT" = "1" ]; then su discourse -c 'bundle exec rake db:migrate'; fi
if [ "$PRECOMPILE_ON_BOOT" = "1" ]; then SKIP_EMBER_CLI_COMPILE=1 su discourse -c 'bundle exec rake assets:precompile'; fi
if [ "$MIGRATE_ON_BOOT" = "1" ]; then
su discourse -c 'bundle exec rake db:migrate' || exit 1
fi
if [ "$PRECOMPILE_ON_BOOT" = "1" ]; then
SKIP_EMBER_CLI_COMPILE=1 su discourse -c 'bundle exec rake assets:precompile' || exit 1
fi
LD_PRELOAD=$RUBY_ALLOCATOR HOME=/home/discourse USER=discourse exec thpoff chpst -u discourse:www-data -U discourse:www-data bundle exec config/unicorn_launcher -E production -c config/unicorn.conf.rb

- file:
Expand Down
Loading