theory/pgenv

use '-mf' on stop

Closed this issue · 9 comments

Any reason not to use -mf when the script calls pg_ctl stop ? Or maybe allow us to pass args:

pgenv stop -mf

That way we can pass -mf or -mi or -ms as needed?

I don't think it works with all versions of PostgreSQL. I don't find that it takes much time to shut down, though; do you?

according to the online docs on the .org site, -mode goes all the way back to 7.1

I was a little confused in the beginning, since on recent versions fast is the default stopping mode, as opposed to smart that was the default for 9 and 8.
Since stop in pg_ctl accept pretty much no other arguments than the mode, I propose to let the user pass a second argument with the mode and use it (with an appropriate default) as:

pgenv stop immediate

But this will soon open the question about why not let any command (e.g., start) to accept arguments.
Another option could be to raise the timeout as a default.

I've created an implementation that accepts a stop mode for both stop and restart.
If that sounds good, I can merge it.
@theory maybe we should elaborate more on "common parts" for pg_ctl?

Allowing an argument makes sense to me, but rather than making smart the default, since I think older versions don't have that option, don't pass an option at all if none is specified. That will let pg_ctl use whatever default it deems appropriate.

Might be useful to add a config variable, too. We'll have to look at supporting a config file or something soon, so that people can set them easily.

I don't know what you mean by the “"common parts" for pg_ctl”, @fluca1978. Can you elaborate?

@theory we use pg_ctl within start, stop and restart, and I believe we should use it also for initdb. Therefore we could try to compact and merge all the above commands to act as "wrappers" for pg_ctl.

With regard to the configuration file, I guess the simplest and easy way to implement is by source-ing a bash file that contains appropriate variables (and defaults). But I don't like this kind of script ot have a stored configuration (my opinion, of course).

@theory can you please review the commit a54def3? Is that what you meant?

Yeah, a54def3 looks good.

I think pg_ctl didn't support initdb in earlier versions.

Yes, exactly source a script with the variables, should be okay if the file doesn't exist, and agree not to commit one; in fact, it should be in .gitignore.