more settings of systemd for postgress

This commit is contained in:
Artur Gurgul1 2025-08-07 21:05:37 +02:00
parent 688d23527f
commit dd1c82e804
5 changed files with 35 additions and 19 deletions

View file

@ -41,7 +41,15 @@ module Setup
pg_hba_path = "#{File.join(context.data_dir, "pg_hba.conf")}"
write_as(context.user_name, pg_hba_path, pg_hba)
postgresql_conf = render("postgresql.conf")
# TODO: move this to user module
uid = Etc.getpwnam(context.user_name.to_s).uid
socket_path = "/run/user/#{uid}"
system("sudo mkdir -p #{socket_path}")
system("sudo chown #{context.user_name}:services #{socket_path}")
system("sudo chmod 700 #{socket_path}")
postgresql_conf = render("postgresql.conf", unix_socket: socket_path)
postgresql_conf_path = "#{File.join(context.data_dir, "postgresql.conf")}"
write_as(context.user_name, postgresql_conf_path, postgresql_conf)
@ -53,11 +61,13 @@ module Setup
)
postgres_service_path = "/etc/systemd/system/postgresql.service"
write_as("root", postgres_service_path, postgres_service)
system("sudo systemctl daemon-reexec")
system("sudo systemctl daemon-reload")
system("sudo systemctl enable postgresql")
system("sudo systemctl start postgresql")
# debug service
# sudo systemctl daemon-reexec && sudo systemctl daemon-reload && sudo systemctl restart postgresql.service
end
def self.install(context)