Forum OpenACS Development: db_source_sql_file and remote PG servers

Don/Dan/Ben,

I am working for a client who wanted to separate the DB server from their webservers. Currently, the db_source_sql_file does not support remote PG servers. So I hardcoded the hostname to test make sure that AOLServer could talk with the remote PG server (see code below).

If you want, I can code up a db proc similar to db_get_port in /web/vtec/packages/acs-tcl/tcl/00-database-procs-postgresql.tcl and make sure it works correctly.

db_source_sql_file:

    set pgport [db_get_port]
    if { ![string equal $pgport ""] } {
        set pgport "--port $pgport"
    }
       
    set pghost "-h dohc"
 
    cd [file dirname $file]
    set fp [open "|[file join [db_get_pgbin] psql] $pghost $pgport 
$pguser -f $f
ile_name [db_get_database]" "r"]
Collapse
Posted by Don Baccus on
It turns out that we need "-h" on windows regardless, so I'm adding code to do this in this case.

We could probably do it in all cases?  I assume it is ignored under Unix/Linux when you're running postmaster without "-i".

I'll be committing my change for windows in a couple of days, I may play with this under Linux and just stick it in for all platforms afterwards.

Can anyone think of any reason NOT to do this?

Collapse
Posted by Don Baccus on
Damn, unless you use "-i" when running postmaster, "-h" fails (telling you you're not running "-i", of course!).

We don't want to force folks to run "-i" all the time, as accepting outside connections raises security issues folks don't want to deal with unless absolutely necessary.

I'll look into having this routine use "-h" when appropriate under Linux/Unix, and add the code to do it always under windows - soon.

Collapse
Posted by Gilbert Wong on
Yes I am running -i, but the db server is on a private network behind the webserver.  So that should be safe, unless I've missed something.
Collapse
Posted by Pascal Scheffers on
An alternate solution would be to set the PGHOST environment variable for Aolserver. That way you do not need to change boot-strapper (Should be done, but maybe not now).