On 9/22/14, frantisek holop <min...@obiit.org> wrote:
>
> i installed postgresql and starting to use it for
> first time.  here is what i think could be improved.

Hmm...

> 1.
> i think the postgres package readme could mention,
> that while there is no default database location
> the rc.d script has /var/postgresql/data hardcoded
> in it.
>
>
> 2.
> without actually initializing a database i tried:

Why did you do this?
The README is clear about creating the database:

  "If you are installing PostgreSQL for the first time, you have to create
  a default database first."



> $ sudo /etc/rc.d/postgresql start
> postgresql(ok)                                        # ???
> $ sudo /etc/rc.d/postgresql check
> postgresql(failed)
>
> a bit of "set -x" reveals:
> $ sudo su -l -c daemon -s /bin/sh _postgresql -c \
>       "/usr/local/bin/pg_ctl -D /var/postgresql/data \
>       start -l /var/postgresql/logfile"
> server starting
> $ echo $?
> 0
> # tail -1 /var/postgresql/logfile
> postgres cannot access the server configuration file
> "/var/postgresql/data/postgresql.conf": No such file or directory
>
> what happens is, that pg_ctl's return code cannot
> be trusted because it starts the server in background
> and does not wait for confirmation. to really make
> sure the server was started, -w must be used:
>
> $ sudo su -l -c daemon -s /bin/sh _postgresql -c \
>       "/usr/local/bin/pg_ctl -w -D /var/postgresql/data \
>       start -l /var/postgresql/logfile"
> waiting for server to start........ stopped waiting
> pg_ctl: could not start server
> Examine the log output.
> $ echo $?
> 1
>
> i dont know how long it takes to start up a huge
> postgres installation with -w, and maybe it is good
> to have it start in the background at startup time,
> but it can mask startup errors like this...
>
>
> 3.
> my last issue is "check": i think it is a bit of overkill
> that i have to be root to check if postgres is running.
> this is because daemon_user is defined. so not even
> '_postgresql' is allowed to check, although it
> is allowed to run the actual 'pg_ctl check' command.
>
> i think it would make sense to get rid of rc_usercheck=NO,
> all of rc_check() and override pexp= to the actual
> daemon signature instead of pg_ctl..  this way any user
> can run the check.

The database could be in a shutdown mode, and
the change you propose could give a false-positive.

Maybe there are reasons why folks who have maintained
this port, and have used it in production, for much longer
than "first time", have things this way.

--patrick



> please find attached my patch that tries to remedy
> the issues mentioned above.
>
> -f
> --
> the best way out of a difficulty is through it.
>

Reply via email to