Skip to content
Closed
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
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not duplicate that logic here. The right place to do it is in the internal binary that already generates these for our current setup.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@darora ok I will look into how to add that appropriately in admin-api closing this

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
Loading