Skip to content
Open
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
5 changes: 1 addition & 4 deletions postgres/.flox/env.json
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
{
"name": "postgres",
"version": 1
}
{"owner":"stahnma","name":"postgres","floxhub_url":"https://hub.flox.dev/","version":1}
5 changes: 5 additions & 0 deletions postgres/.flox/env.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rev": "9828552766d58320783433f6279433a634e8ed3c",
"local_rev": "34a6951f28378f39cb1f2456157e9e1144e72278",
"version": 1
}
4 changes: 2 additions & 2 deletions postgres/.flox/env/manifest.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"PGUSER": "pguser"
},
"hook": {
"on-activate": "\nexport PGDIR=\"$FLOX_ENV_CACHE/postgres\"\nexport PGDATA=$PGDIR/data\nexport PGHOST=$PGDIR/run\nexport PGCONFIGFILE=\"$PGDIR/postgresql.conf\"\nexport LOG_PATH=$PGHOST/LOG\nexport SESSION_SECRET=\"$USER-session-secret\"\nexport DATABASE_URL=\"postgresql:///$PGDATABASE?host=$PGHOST&port=$PGPORT\"\n\nif [[ ! -d \"$PGHOST\" ]]; then\n mkdir -p \"$PGHOST\"\nfi\n\nif [[ ! -d \"$PGDATA\" ]]; then\n mkdir -p \"$PGDATA\"\n pg_initdb() {\n initdb \"$PGDATA\" \\\n --locale=C \\\n --encoding=UTF8 \\\n -A md5 \\\n --auth=trust \\\n --username $PGUSER \\\n --pwfile=<(echo $PGPASS)\n }\n export -f pg_initdb # This is needed for gum to be able to call function\n if [[ \"$FLOX_ENVS_TESTING\" == \"1\" ]]; then\n pg_initdb\n else\n gum spin --spinner dot --title \"Running initdb in $PGDATA\" -- bash -c pg_initdb\n fi\n echo \"✅ Initialize PostgreSQL ($PGDATA)\"\n\nfi\n\n\n#\nif [[ ! -f \"$PGCONFIGFILE\" ]]; then\n tee -a $PGCONFIGFILE > /dev/null << EOF\nlisten_addresses = '$PGHOSTADDR';\nport = '$PGPORT';\nunix_socket_directories = '$PGHOST';\nunix_socket_permissions = '0700';\nEOF\n echo \"✅ Configure PostgreSQL ($PGCONFIGFILE)\"\nfi\n\npg_ctl -D \"$PGDATA\" -w start -o \"-c unix_socket_directories=$PGHOST -c listen_addresses=$PGHOSTADDR -p $PGPORT\" > /dev/null\nif psql -lqt | cut -d \\| -f 1 | grep -qw $PGDATABASE; then\n echo \"✅ Database '$PGDATABASE' already exists\"\nelse\n createdb\n echo \"✅ Database '$PGDATABASE' created\"\nfi\npg_ctl -D \"$PGDATA\" -m fast -w stop > /dev/null\n\ngum style --border double --margin \"1 2\" --padding \"1 4\" \\\n 'Start PostgreSQL in the background:' \\\n ' 👉 flox services start' \\\n ' 👉 flox activate --start-services' '' \\\n 'Try to connect to PostgreSQL:' \\\n ' 👉 psql' '' \\\n 'Connection information:' \\\n \" listen_addresses=$PGHOSTADDR\" \\\n \" port=$PGPORT\"\n\n"
"on-activate": "\nexport PGDIR=\"$FLOX_ENV_CACHE/postgres\"\nexport PGDATA=$PGDIR/data\nexport PGHOST=$PGDIR/run\nexport PGCONFIGFILE=\"$PGDIR/postgresql.conf\"\nexport LOG_PATH=$PGHOST/LOG\nexport SESSION_SECRET=\"$USER-session-secret\"\nexport DATABASE_URL=\"postgresql:///$PGDATABASE?host=$PGHOST&port=$PGPORT\"\n\nif [[ ! -d \"$PGHOST\" ]]; then\n mkdir -p \"$PGHOST\"\nfi\n\nif [[ ! -d \"$PGDATA\" ]]; then\n mkdir -p \"$PGDATA\"\n pg_initdb() {\n initdb \"$PGDATA\" \\\n --locale=C \\\n --encoding=UTF8 \\\n -A md5 \\\n --auth=trust \\\n --username $PGUSER \\\n --pwfile=<(echo $PGPASS)\n }\n export -f pg_initdb # This is needed for gum to be able to call function\n if [[ \"$FLOX_ENVS_TESTING\" == \"1\" ]]; then\n pg_initdb\n else\n gum spin --spinner dot --title \"Running initdb in $PGDATA\" -- bash -c pg_initdb\n fi\n echo \"✅ Initialize PostgreSQL ($PGDATA)\"\n\nfi\n\n\n#\nif [[ ! -f \"$PGCONFIGFILE\" ]]; then\n tee -a $PGCONFIGFILE > /dev/null << EOF\nlisten_addresses = '$PGHOSTADDR';\nport = '$PGPORT';\nunix_socket_directories = '$PGHOST';\nunix_socket_permissions = '0700';\nEOF\n echo \"✅ Configure PostgreSQL ($PGCONFIGFILE)\"\nfi\n\npg_ctl -D \"$PGDATA\" -w start -o \"-c listen_addresses=$PGHOSTADDR -p $PGPORT\" > /dev/null\nif psql -lqt | cut -d \\| -f 1 | grep -qw $PGDATABASE; then\n echo \"✅ Database '$PGDATABASE' already exists\"\nelse\n createdb\n echo \"✅ Database '$PGDATABASE' created\"\nfi\npg_ctl -D \"$PGDATA\" -m fast -w stop > /dev/null\n\ngum style --border double --margin \"1 2\" --padding \"1 4\" \\\n 'Start PostgreSQL in the background:' \\\n ' 👉 flox services start' \\\n ' 👉 flox activate --start-services' '' \\\n 'Try to connect to PostgreSQL:' \\\n ' 👉 psql' '' \\\n 'Connection information:' \\\n \" listen_addresses=$PGHOSTADDR\" \\\n \" port=$PGPORT\"\n\n"
},
"options": {
"systems": [
Expand All @@ -30,7 +30,7 @@
},
"services": {
"postgres": {
"command": "postgres -D $PGDATA -c unix_socket_directories=$PGHOST -c listen_addresses=$PGHOSTADDR -p $PGPORT"
"command": "postgres -D $PGDATA -c listen_addresses=$PGHOSTADDR -p $PGPORT"
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions postgres/.flox/env/manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ EOF
echo "✅ Configure PostgreSQL ($PGCONFIGFILE)"
fi

pg_ctl -D "$PGDATA" -w start -o "-c unix_socket_directories=$PGHOST -c listen_addresses=$PGHOSTADDR -p $PGPORT" > /dev/null
pg_ctl -D "$PGDATA" -w start -o "-c listen_addresses=$PGHOSTADDR -p $PGPORT" > /dev/null
if psql -lqt | cut -d \| -f 1 | grep -qw $PGDATABASE; then
echo "✅ Database '$PGDATABASE' already exists"
else
Expand All @@ -92,7 +92,7 @@ gum style --border double --margin "1 2" --padding "1 4" \
'''

[services]
postgres.command = "postgres -D $PGDATA -c unix_socket_directories=$PGHOST -c listen_addresses=$PGHOSTADDR -p $PGPORT"
postgres.command = "postgres -D $PGDATA -c listen_addresses=$PGHOSTADDR -p $PGPORT"


[options]
Expand Down
Loading