On two node HA cluster I'm using pacemaker to manage HA. Database files are placed on drbd block device. On active node everything is ok, `/etc/init.d/postgresql-9.4 status` returns "started" with error code "0". It's ok. On other node drbd resource is in slave state, so filesystem with postgres database is unmounted. On this node service status returns: # /etc/init.d/postgresql-9.4 status * Checking PostgreSQL 9.4 status ... pg_ctl: directory "/data/pgsql/9.4" does not exist [ !! ] with error code "4". And this error code makes problem for pacemaker, pacemaker assumes that something is wrong with service and cluster HA is in not HA state ;) This resource will not be managed by pacemaker. Reproducible: Always Expected Results: /etc/init.d/postgresql-9.4 should return code "3" if pg_ctl doesn't find database directory.
The initscript just passes along the exit code it receives from pg_ctl. ~ # rc-service postgresql-9.6 status * Checking PostgreSQL 9.6 status ... pg_ctl: directory "/var/lib/postgresql/9.6/data" does not exist [ !! ] ~ # echo $? 4 This error code is documented upstream as the code to expect when the directory can't be found. From https://www.postgresql.org/docs/9.4/static/app-pg-ctl.html: > If an accessible data directory is not specified, the process returns an exit status of 4. Basically, it's stating that not only is the server not running, there's no data for it to work with in the first place. You'll need to fix your implementation because the initscript is doing the right thing.