1

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.

1

So I did eventually solve the problem, here's the answer for anyone who'd face the same problem. The mistake was actually quite dumb but I got to notice it only after I got to know how logging works in void, somehow only the syslog (but not the postgres log) did show the error that read SSL is not supported in this build, so I started digging that way and eventually came up to realize that -l flag in the service execution command forces SSL usage, which I didn't need. So the final run file with which I got it all working is:

# /etc/sv/postgresql/run:
#!/bin/sh
exec chpst -u postgres:postgres /usr/local/pgsql/bin/postgres -D '/var/lib/postgresql/data' 2>&1

Also, logging for the service is enabled by creating a folder /etc/sv/postgresql/log and creating a file in it (/etc/sv/postgresql/log/run) with contents:

#!/bin/sh
exec logger -p daemon.info -t postgres

Also install a syslog daemon to actually get logs stored (for ex. socklog-void)

  • It's all too often we think our answers haven't made a difference to anyone else, but today yours has. Thanks for saving me a few hours of debugging time :) – stevenhaddox Oct 16 at 5:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.