Skip to content

Commit

Permalink
feat: control shared_buffers value if oriole prior to start
Browse files Browse the repository at this point in the history
  • Loading branch information
samrose committed Nov 28, 2024
1 parent 1a42585 commit b247bc1
Showing 1 changed file with 30 additions and 17 deletions.
47 changes: 30 additions & 17 deletions ansible/files/postgres_prestart.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,44 @@ get_shared_buffers() {
update_orioledb_buffers() {
local pg_conf="/etc/postgresql/postgresql.conf"
local value="$1"

# Update orioledb.main_buffers
if grep -q "^orioledb.main_buffers = " "$pg_conf"; then
sed -i "s/^orioledb.main_buffers = .*/orioledb.main_buffers = $value/" "$pg_conf"
else
echo "orioledb.main_buffers = $value" >> "$pg_conf"
fi
}

main() {
local has_orioledb=$(check_orioledb_enabled)
if [ "$has_orioledb" -lt 1 ]; then
return 0
fi
local shared_buffers_value=$(get_shared_buffers)
if [ ! -z "$shared_buffers_value" ]; then
update_orioledb_buffers "$shared_buffers_value"

# Update shared_buffers during alpha release to 32MB
# TODO will need to add logic here for different ec2 sizes
if grep -q "^shared_buffers = " "$pg_conf"; then
sed -i "s/^shared_buffers = .*/shared_buffers = 32MB/" "$pg_conf"
else
echo "shared_buffers = 32MB" >> "$pg_conf"
fi
}

# Initial locale setup
if [ $(cat /etc/locale.gen | grep -c en_US.UTF-8) -eq 0 ]; then
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
fi
setup_locales() {
# Initial locale setup
if [ $(cat /etc/locale.gen | grep -c en_US.UTF-8) -eq 0 ]; then
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
fi

if [ $(locale -a | grep -c en_US.utf8) -eq 0 ]; then
locale-gen
fi
if [ $(locale -a | grep -c en_US.utf8) -eq 0 ]; then
locale-gen
fi
}

main() {
setup_locales
local has_orioledb=$(check_orioledb_enabled)
if [ "$has_orioledb" -lt 1 ]; then
return 0
fi
local shared_buffers_value=$(get_shared_buffers)
if [ ! -z "$shared_buffers_value" ]; then
update_orioledb_buffers "$shared_buffers_value"
fi
}

main

0 comments on commit b247bc1

Please sign in to comment.