How to start PGBouncer autostart on reboot on Linux?

On Ubuntu 12.04 (exact) on a Windows Azure VM, I have postgres and pgbouncer running on the same computer. Everything is configured and working, however, when the VM reboots, pgbouncer does not start automatically.

  • How do I make it start with a reboot?
  • Should Postgres work before PGBouncer? If so, how is this achieved? I assume PGBouncer will work anyway, only any sql connections will not connect if Postgres is down or is this assumption wrong?

The commands that run to run are as follows. Note. I need to be a postgres user to start the service, otherwise it failed. Also a detailed answer preferrend. Linux is not my regular OS.

sudo su postgres
pgbouncer -d -v /etc/pgbouncer/pgbouncer.ini

If this is useful, then pgbouncer is installed:

sudo apt-get install postgresql-9.3 pgbouncer

Note. I can interact with the pgbouncer service (forced restart, status, start, stop), but only after I first run the command pgbouncer -d -v /etc/pgbouncer/pgbouncer.ini.

+4
source share
1 answer

Change /etc/default/pgbouncerand install

START=1

Then run pgbouncerusing the init script:

/etc/init.d/pgbouncer start

The init script will automatically run pgbouncer at boot time. But you need to do the setup START=1.

+9
source

All Articles