If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 > install postgre service manually

 isaac_cm Registered User Join Date: Aug 2009 Posts: 17
install postgre service manually

 hello, I need to use postgre on a desktop application, and I need to install the service manually and use another port than the standard "5432" to prevent a conflict please advice how I can do that with setup tools or without them Thanks
 shammat Registered User Join Date: Nov 2003 Posts: 2,799
 This can be done by calling pg_ctl using the -register parameter. The port can specified when running initdb and is then put into postgresql.conf so so you don't really need to specify it for the service. But you can also specify the port with the -o option Details are here: http://www.postgresql.org/docs/current/static/app-pg-ctl.html But you don't really need a service, you can start the postgres server by simply running pg_ctl directly when you startup the application: Code: pg_ctl -o "-p 5433 -D \path\to\datadir" start
 isaac_cm Registered User Join Date: Aug 2009 Posts: 17
 This is a great answer, How I can thank you ?? Appreciate your help one question, is there a way to bypass firewalls like kaspersky to prevent closing of the port ?

Last edited by isaac_cm; 08-11-09 at 07:44.
 shammat Registered User Join Date: Nov 2003 Posts: 2,799
Quote:
 Originally Posted by isaac_cm one question, is there a way to bypass firewalls like kaspersky to prevent closing of the port ?
I don't think so although probably some virus hacker would be able to do that

It is possible to run Postgres completely without it listening on a port. It will then only allow connections through Unix-domain sockets, but I don't believe this will work on Windows. Nor would I know how to use it.

Edit: I have a set of batch files that automatically initialize a Postgres database and start the server from the commandline without a service. I created them to quickly setup a development server ("Postgres to go"). They are using the binary ZIP distribution from EnterpriseDB and not the installer

If you are interested, I can post those files here.
 isaac_cm Registered User Join Date: Aug 2009 Posts: 17
 sure, plz do, but why only for developing, is there a problem to use them in customers pc ?
 shammat Registered User Join Date: Nov 2003 Posts: 2,799
Quote:
 Originally Posted by isaac_cm but why only for developing, is there a problem to use them in customers pc ?
Well that was the use case for me
For a production environment with a dedicated Postgres server you will definitely want to have the service installation in order to make sure Postgres is always up and running.

And the startup through a batch file has the disadvantage that you'll have a console window open which is also not ideal for a production environment.

I have attached the batch files.

They assume that the ZIP distribution is unzipped into the folder where the files are located into a sub-directory called "server". The data directory will be created in the same folder

So the directory will be:

Code:
postgres
server
(unzipped binary archive)
bin
share
lib
...
The bare minimum to be extracted from the ZIP archive are the directories bin, lib and share

The other stuff (e.g pgAdmin) is optional and not required to run the server.

The batch file initialize.cmd is also adjusting some of the more conservative parameters in the postgresql.conf file.

For this it uses a tool called "Swiss File Knife" to replace the default values. You need to either comment those lines, or download sfk.exe from here.
http://sourceforge.net/projects/swissfileknife/

If you want to run Postgres on a different port, you can either supply the parameter in the commandline for initdb (initialize.cmd, line 24) or extend the section that changes the postgresql.conf file to replace the default port with your desired one.
Attached Files
 batchfiles.zip (2.3 KB, 76 views)
 isaac_cm Registered User Join Date: Aug 2009 Posts: 17
 Ok, many thanks After I modify the postgresql.conf, what is the command to install the service permanently on the pc ?
 shammat Registered User Join Date: Nov 2003 Posts: 2,799
Quote:
 Originally Posted by isaac_cm After I modify the postgresql.conf, what is the command to install the service permanently on the pc ?
As I said, use pg_ctl with the -register parameter.
See the link to the manual that I posted for details.