Running PostgreSQL as a service under Windows XP Pro (using 'cygrunsrv') - Mailing list pgsql-cygwin

From Cédric Dufour
Subject Running PostgreSQL as a service under Windows XP Pro (using 'cygrunsrv')
Date
Msg-id NDBBIFNBODNADCAOFDOAGEIHCDAA.cedric.dufour@freesurf.ch
Whole thread Raw
Responses Re: Running PostgreSQL as a service under Windows XP Pro  (Jason Tishler <jason@tishler.net>)
ipc-daemon cannot run as an NT service under latest Cygwin CVS  (Jason Tishler <jason@tishler.net>)
List pgsql-cygwin
Hello there,
 
I've been struggling the last couple of hours to install PostgreSQL as a service in Windows XP Pro and eventually suceeded, despite the lack of 'tips & tricks' on the various mailing lists (though many people seem to have problems too). I compiled a small HOWTO, which (part of the) content might be helpful in the Windows part of the PostgreSQL installation documentation. The main difficulties I encountered are:
1. 'ipc-daemon --install-as-service' doesn't seem to work on Windows XP (it generates a timeout error when trying to start the service -> use 'cygrunsrv' instead to launch the daemon)
2. 'chown <PostgreSQL user> <...>/PostgreSQL/data' doesn't seem to work either (one has to create the directory when logged in as the <PostgreSQL user>, thanx M$)
3. <PostgreSQL user> has to be granted additional privileges (cf. Windows security policies) in order to be able to launch a service
4. Cygwin temporary folder ('/tmp') and Cygrunsrv output files (cf '--stdout' and '--stderr' options) must be read/write accessible to <PostgreSQL user> (which is most likely not the case if <PostgreSQL user> is not part of the 'administrators' group... and no user should actually be part of this group unless absolutely necessary)
 
These issues might be obvious for some but seem to drive some other to despair (as I almost did). I hope this information might be helpful to the PostgreSQL community.
 
Regards,
 
Cédric Dufour
 
PostgreSQL under Windows XP
===========================
( NB: Tested on Windows XP Pro; no warranties for Windows XP Home )
 
In order to have PostegreSQL running as a service under Windows XP, follow the instructions below.
 
CygWin and IPC:
---------------
 
1. Install CygWin
   NB: Make sure to include 'cygipc' (ipc-daemon), 'cygrunsrv' and 'postgresql' modules during the installation
 
2. Install the IPC daemon as a Windows service
   > cygrunsrv --install CygIPC --desc "CygWin IPC Daemon" --path /usr/local/bin/ipc-daemon --termsig INT --shutdown
   NB: 'ip-daemon --install-as-service' doesn't seem to work on Windows XP
 
PostgreSQL:
-----------
 
1. Create a 'SRV_PostgreSQL' user (or whatever other user name) using Windows user manager
   NB: Make sure this user has read/write access to the CygWin 'tmp' directory and to the PostgreSQL log files (cf. '--stdout' and '--stderr' options below)
 
2. Add the new user to CygWin password list
   > mkpasswd -l -u SRV_PostgreSQL >> /etc/passwd
 
3. Create the PostgreSQL data directory
   > mkdir <...>/PostgreSQL/data
 
4. Change the directory owner
   > chown SRV_PostgreSQL <...>/PostgreSQL/data
   NB: For some reasons, this doesn't work on Windows XP -> create the directory manually, logging in as 'SRV_PostgreSQL' user
 
5. Initialize the database
   > initdb -D <...>/PostgreSQL/data
 
6. Install PostgreSQL server as a Windows service
   > cygrunsrv --install PostgreSQL --desc "PostgreSQL Database Server" --path /usr/bin/postmaster --args "-D <...>/PostgreSQL/data -i" --dep ipc-daemon --termsig INT --user SRV_PostgreSQL --shutdown --stdout <...>/postgresql.log --stderr <...>/postgresql.err
   NB: In order to launch the service under the 'SRV_PostgreSQL' user, make sure it has been granted the right to launch services (cf. Windows security policies); one way to make sure of this is to open the Service Management Console and edit the 'Log On' properties of the newly created service, so that Windows automatically grant the required privileges to the 'Log On' account
 
DONE !
 
25.07.2002 - C.Dufour (cedric.dufour@freesurf.ch)

pgsql-cygwin by date:

Previous
From: "Pankaj Naug"
Date:
Subject: reject
Next
From: Jason Tishler
Date:
Subject: Re: Running PostgreSQL as a service under Windows XP Pro