I'm trying to get my head around Voidlinux and runit in particular. Void had postgresql v9 in its repos, I needed something newer, so I compiled v12 from source. It works ok, but now I'm struggling with creating a runit service for it, I've read some manuals, googled a bit and here's what I came up with:
# /etc/sv/postgresql/run
#!/bin/sh
exec chpst -u postgres /usr/local/pgsql/bin/pg_ctl -D /var/lib/postgresql/data -l /var/lib/postgresql/logfile start 2>&1
# I've also tried postmaster command, which doesn't work even as standalone, whereas I'm able to launch the server by hand with the command above
I've also tried creating an empty directory in /run/runit/supervise.postgresql
and linking it to /etc/sv/postgresql
(as well as without it)
After I reboot (or try to manually start the service), I'm getting output:
waiting for server to start.... done
server started
pg_ctl: another server might be running; trying to start server anyway
waiting for server to start.... stopped waiting
pg_ctl: could not start server
Examine the log output.
Then the last 4 lines are repeated in an endless loop with no result.
Contents of /var/lib/postgresql/logfile
:
2019-05-10 08:11:15.859 CEST [1138] FATAL: lock file "postmaster.pid" already exists
2019-05-10 08:11:15.859 CEST [1138] HINT: Is another postmaster (PID 760) running in data directory "/var/lib/postgresql/data"?
2019-05-10 08:11:16.964 CEST [1211] FATAL: lock file "postmaster.pid" already exists
2019-05-10 08:11:16.964 CEST [1211] HINT: Is another postmaster (PID 760) running in data directory "/var/lib/postgresql/data"?
2019-05-10 08:11:18.070 CEST [1215] FATAL: lock file "postmaster.pid" already exists
2019-05-10 08:11:18.070 CEST [1215] HINT: Is another postmaster (PID 760) running in data directory "/var/lib/postgresql/data"?
Thanks.