From psql docs (https://www.postgresql.org/docs/current/app-psql.html):
> psql returns 0 to the shell if it finished normally, 1 if a fatal
error of its own occurs (e.g., out of memory, file not found), 2 if the
connection to the server went bad and the session was not interactive,
and 3 if an error occurred in a script and the variable ON_ERROR_STOP
was set.
Also resolves https://github.com/juspay/services-flake/issues/107
This commit resolves the issue where `pg_isready` would fail when
`socketDir` is set and `listen_addresses` is empty. `pg_isready` is now
modified to leverage `socketDir` when it is available.
If the socketDir is in tmpfs, or if it is deleted by some other process, we would want the socketDir to be created, if not already present, on restarts.
* Added option depends_on which will be useful to append extra depends_on configuration to the <name>-init process.
* more meaningful `depends_on` option's description
---------
Co-authored-by: shivaraj-bh <sbh69840@gmail.com>
* Use psql instead of postgres, as a result, use `pg_ctl` to temporarily start the postgres server in `${name}-init` process.
* Avoid creating a custom `postgresPkg` with extensions by using `apply` attribute provided by `mkOption`
* Refactor setup script, use `writeShellApplication` and resolve shell-check errors
---------
Co-authored-by: shivaraj-bh <sbh69840@gmail.com>