From: | Craig Ringer <craig(at)postnewspapers(dot)com(dot)au> |
---|---|
To: | Jensen Somers <jensen(at)aimproductions(dot)be> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Install PostgreSQL as part of a desktop application, but how to coop with existing installations? |
Date: | 2011-01-14 06:35:11 |
Message-ID: | 4D2FEE9F.1080306@postnewspapers.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 01/14/2011 06:26 AM, Jensen Somers wrote:
> I know that some applications (Poker Tracker 3 is the first one that
> comes to my mind)
It's not a good example, either, as demonstrated by the number of
questions that pop up about it on this list, and the incredibly ancient
versions of Pg that they bundle.
> install PostgreSQL during their installation process
> too and setup the initial database. I sort of figured out how to do
> this, but I don't know how to deal with an already existing installation
> during setup.
I take it you're talking about doing a silent install using the
postgresql exe installer, by invoking it as part of your own app's
installer?
Personally, that's not how I'd do it if I were bundling Pg in my
(Windows) app, because as you mentioned it may interfere with any
existing or future Pg install the user wants to do manually. It'll also
show up separately in add/remove programs, which I think is undesirable
when it's just being installed as a component of your app.
If my app required Pg, I'd probably bundle the Pg installation tree in
my installer and copy it into my program's install directory. I'd then
create a non-login user account named after my application (NOT
"postgres"), set up the service (again named for my application), and
invoke initdb to create the database under that service account. I'd
generate a postgresql.conf with a semi-random fairly high port number
that wasn't already in use on the target machine, to avoid conflicting
with the commonly used postgresql port. All this can be done using the
scripting languages provided by most installers, or via simple Windows
command line tools like "net.exe" and friends. If your installer is
particularly limited, you can always write and bundle a simple helper
program for it to invoke to do the work. My uninstaller would prompt the
user to ask if they wanted to remove data as well as the program; if
they said yes I'd remove the datadir and the user account I'd created
during installation.
This way, your instance of PostgreSQL is private to your app and doesn't
conflict with anything the user might want to do. You can upgrade it
when you upgrade your app, provide backup facilities for it in your app,
etc etc without the user having to care what's behind the scenes.
If that wasn't viable, the only other option I'd consider would be
providing a postgresql installer and asking the user to install it if
they didn't already have it installed. I'd then prompt for the database
host, port, username, password and database name to connect to, and
would just use what was provided to me. This is almost certainly how it
should be done on UNIX/Linux platforms.
--
Craig Ringer
From | Date | Subject | |
---|---|---|---|
Next Message | Jensen Somers | 2011-01-14 07:45:11 | Re: Install PostgreSQL as part of a desktop application, but how to coop with existing installations? |
Previous Message | Craig Ringer | 2011-01-14 06:17:37 | Re: Stuck "idle in transaction (aborted)" |