Skip to content

Commit

Permalink
add postgres daemon files
Browse files Browse the repository at this point in the history
  • Loading branch information
Ifiht committed Sep 11, 2024
1 parent 299324d commit 5b25d4f
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/modules/database/init_db.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
require 'sqlite3'
# OS Requirements:
#> sudo apt install -y postgresql-common
#> sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
#> sudo apt install postgresql-16

# Open a database
db = SQLite3::Database.new "XPlatform_Chat.db"
Expand Down
98 changes: 98 additions & 0 deletions src/modules/postgres/data/postgresql.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# -----------------------------
# PostgreSQL configuration file
# -----------------------------
#
# This file consists of lines of the form:
#
# name = value
#
# (The "=" is optional.) Whitespace may be used. Comments are introduced with
# "#" anywhere on a line. The complete list of parameter names and allowed
# values can be found in the PostgreSQL documentation.
#
# The commented-out settings shown in this file represent the default values.
# Re-commenting a setting is NOT sufficient to revert it to the default value;
# you need to reload the server.
#
# This file is read on server startup and when the server receives a SIGHUP
# signal. If you edit the file on a running system, you have to SIGHUP the
# server for the changes to take effect, run "pg_ctl reload", or execute
# "SELECT pg_reload_conf()". Some parameters, which are marked below,
# require a server shutdown and restart to take effect.
#
# Any parameter can also be given as a command-line option to the server, e.g.,
# "postgres -c log_connections=on". Some parameters can be changed at run time
# with the "SET" SQL command.
#
# Memory units: B = bytes Time units: us = microseconds
# kB = kilobytes ms = milliseconds
# MB = megabytes s = seconds
# GB = gigabytes min = minutes
# TB = terabytes h = hours
# d = days

#------------------------------------------------------------------------------
# FILE LOCATIONS
#------------------------------------------------------------------------------
# The default values of these variables are driven from the -D command-line
# option or PGDATA environment variable, represented here as ConfigDir.

#data_directory = '/var/lib/postgresql/16/main' # use data in another directory (change requires restart)
#hba_file = '/etc/postgresql/16/main/pg_hba.conf' # host-based authentication file (change requires restart)
#ident_file = '/etc/postgresql/16/main/pg_ident.conf' # ident configuration file (change requires restart)
# If external_pid_file is not explicitly set, no extra PID file is written.
#external_pid_file = '/var/run/postgresql/16-main.pid' # write an extra PID file (change requires restart)

#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------
# - Connection Settings -

listen_addresses = 'localhost' # what IP address(es) to listen on;
port = 5432 # (change requires restart)
max_connections = 80 # (change requires restart)
unix_socket_directories = '/var/run/postgresql' # comma-separated list of directories
# - SSL -
ssl = off

#------------------------------------------------------------------------------
# RESOURCE USAGE (except WAL)
#------------------------------------------------------------------------------
# - Memory -
shared_buffers = 128MB # min 128kB (change requires restart)
dynamic_shared_memory_type = posix # (change requires restart)

#------------------------------------------------------------------------------
# WRITE-AHEAD LOG
#------------------------------------------------------------------------------
# - Settings -
max_wal_size = 1GB
min_wal_size = 80MB

#------------------------------------------------------------------------------
# REPORTING AND LOGGING
#------------------------------------------------------------------------------
# - Where to Log -
log_destination = 'stderr'
log_line_prefix = '%m [%p] %q%u@%d '
log_timezone = 'Pacific/Auckland'

# - Process Title -
cluster_name = '16/main' # added to process titles if nonempty (change requires restart)

#------------------------------------------------------------------------------
# CLIENT CONNECTION DEFAULTS
#------------------------------------------------------------------------------
datestyle = 'iso, mdy'
timezone = 'Pacific/Auckland'
# These settings are initialized by initdb, but they can be changed.
lc_messages = 'en_US.UTF-8' # locale for system error message
lc_monetary = 'en_US.UTF-8' # locale for monetary formatting
lc_numeric = 'en_US.UTF-8' # locale for number formatting
lc_time = 'en_US.UTF-8' # locale for time formatting
# default configuration for text search
default_text_search_config = 'pg_catalog.english'

#------------------------------------------------------------------------------
# CUSTOMIZED OPTIONS
#------------------------------------------------------------------------------
8 changes: 8 additions & 0 deletions src/modules/postgres/wrapper_nostart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/env bash
# OS Requirements:
#> sudo apt install -y postgresql-common
#> sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
#> sudo apt install postgresql-16

echo "Starting PostgreSQL server..."
/usr/lib/postgresql/16/bin/postgres -D . --auth-local peer --auth-host scram-sha-256 --no-instructions

0 comments on commit 5b25d4f

Please sign in to comment.