Skip to main content
Topic: How do you setup PostgreSQL on Runit? (Read 1593 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

How do you setup PostgreSQL on Runit?

Hello,
I downloaded
Code: [Select]
postgresql && postgresql-runit
After that I did this:
Code: [Select]
sudo ln -s /etc/runit/sv/postgresql /run/runit/service

After a reboot I started the service via
Code: [Select]
sudo sv start postgres (I also tried it with postgresql)
and it seemed to work, but after a
Code: [Select]
sudo sv status postgres
it always tells me that the service is down and I can`t create a user/database.
I followed the arch-installation until
Code: [Select]
sudo systemctl enable --now postgresql.service
.

Some information about my System:
  • Kernel-Version: 5.12.14-artix1.1 (64-bit)
  • Postgres-version: 13.3

I hope you can help me.
Thanks in advance!

How do you setup PostgreSQL on Runit?

Reply #1
Sorry, I accidentally replied with my Question.

Re: How do you setup PostgreSQL on Runit?

Reply #2
I'm able to reproduce the issue here.

Running PostgreSQL manually:

Code: [Select]
$ sudo sh -c 'cd /etc/runit/sv/postgresql/ && exec sh -x ./run'
+ [ -r conf ]
+ . ./conf
+ PGROOT=/var/lib/postgres
+ PGLOG=/var/log/postgresql.log
+ INITOPTS=-A peer --auth-host=md5 --auth-local=peer --locale en_US.UTF-8
+ : /var/lib/postgres/data
+ [ /var/lib/postgres != /var/lib/postgres ]
+ [ ! -d /var/lib/postgres/data ]
+ exec chpst -u postgres:postgres postgres -D /var/lib/postgres/data
2021-07-10 10:50:41.123 -03 [20760] LOG:  starting PostgreSQL 13.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 11.1.0, 64-bit
2021-07-10 10:50:41.124 -03 [20760] LOG:  listening on IPv6 address "::1", port 5432
2021-07-10 10:50:41.124 -03 [20760] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2021-07-10 10:50:41.175 -03 [20760] FATAL:  could not create lock file "/run/postgresql/.s.PGSQL.5432.lock": No such file or directory
2021-07-10 10:50:41.180 -03 [20760] LOG:  database system is shut down

I then added the following line to the end of the conf in /etc/runit/sv/postgresql/conf so it'd create the folder it's complaining about not existing:

Code: [Select]
mkdir -p /run/postgresql/ && chown postgres:postgres /run/postgresql

Now it starts successfully here (both from sv start and manually).

Code: [Select]
sudo sh -c 'cd /etc/runit/sv/postgresql/ && exec sh -x ./run'
+ [ -r conf ]
+ . ./conf
+ PGROOT=/var/lib/postgres
+ PGLOG=/var/log/postgresql.log
+ INITOPTS=-A peer --auth-host=md5 --auth-local=peer --locale en_US.UTF-8
+ mkdir -p /run/postgresql/
+ chown postgres:postgres /run/postgresql
+ : /var/lib/postgres/data
+ [ /var/lib/postgres != /var/lib/postgres ]
+ [ ! -d /var/lib/postgres/data ]
+ exec chpst -u postgres:postgres postgres -D /var/lib/postgres/data
2021-07-10 10:55:12.549 -03 [22164] LOG:  starting PostgreSQL 13.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 11.1.0, 64-bit
2021-07-10 10:55:12.549 -03 [22164] LOG:  listening on IPv6 address "::1", port 5432
2021-07-10 10:55:12.549 -03 [22164] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2021-07-10 10:55:12.990 -03 [22164] LOG:  listening on Unix socket "/run/postgresql/.s.PGSQL.5432"
2021-07-10 10:55:13.205 -03 [22170] LOG:  database system was shut down at 2021-07-10 10:54:32 -03
2021-07-10 10:55:13.269 -03 [22164] LOG:  database system is ready to accept connections


Re: How do you setup PostgreSQL on Runit?

Reply #3
Thank you very much! My issue was that I kept running my service
Code: [Select]
sudo sv start postgresql
in the background. After stopping it and restarting it, I could succesfully create my user and a database!

Re: How do you setup PostgreSQL on Runit?

Reply #4
Was that the only issue, or did my suggestion help?

 

Re: How do you setup PostgreSQL on Runit?

Reply #5
Was that the only issue, or did my suggestion help?
You totally solved my Problem. I wrote another answer, because after running your command, it showed me that an lockfile already exists and that there may be another one running this service. But after I
Code: [Select]
sudo mv stop postgresql
and then start it again it worked. But that was not the original solution, as I tried that multiple times yesterday.