Vauxoo / docker-odoo-image

Base docker image for instances
GNU General Public License v2.0
18 stars 29 forks source link

The variable $PSQL_VERSION is not taken into account when starting PostgreSQL #298

Closed luisg123v closed 6 years ago

luisg123v commented 6 years ago

I don't know if this worked, but it seems to not work anymore:

$ pg_lsclusters 
Ver Cluster Port Status Owner Data directory               Log file
9.3 main    5432 down   odoo  /var/lib/postgresql/9.3/main pg_log/postgresql.log
9.5 main    5432 down   odoo  /var/lib/postgresql/9.5/main pg_log/postgresql.log
9.6 main    5432 down   odoo  /var/lib/postgresql/9.6/main pg_log/postgresql.log
10  main    5432 down   odoo  /var/lib/postgresql/10/main  pg_log/postgresql.log
$ echo $PSQL_VERSION 
9.5
$ service  postgresql  start 
 * Starting PostgreSQL 9.3 database server                                                                    [ OK ]
$

Debugging a little, I noticed the value of the variable $PSQL_VERSION is not retrievable in the init scripts, neither in /etc/init.d/postgresql, nor /usr/share/postgresql-common/init.d-functions.

If I try to print the variable inside those scripts, nothing is printed, like if it was undefined.

moylop260 commented 6 years ago

You should use /etc/init.d/postgresql start instead.

Using

I'm using the latest build of the image:

docker pull vauxoo/odoo-80-image-shippable-auto
Using default tag: latest
latest: Pulling from vauxoo/odoo-80-image-shippable-auto
Digest: sha256:01379c9a31a08a47cefd5cab114fc776c7b558b034a7cb6f6ce03835504f8698
Status: Image is up to date for vauxoo/odoo-80-image-shippable-auto:latest
luisg123v commented 6 years ago

@moylop260 I don't like such a workaround. Init scripts are not intended to be called directly anymore.

The ideal solution would be to write all variables in /etc/environment or so, and source that file from the custom script function. For more info, see This StackExchange answer.

Another solution could be to remove the '' from here and, instead of using an harcoded 9.3, take the value set for $PSQL_VERSION at that point.

But well, if it's not possible, I could deal with that.

moylop260 commented 6 years ago

We are using the same WA from travis. Remeber that our image is a copy of travis one with good and bad practices like as virtualenv and init.d/postgresql script modified

luisg123v commented 6 years ago

:+1: I understand, thanks for the explanation.