Postgres: Starting Server in background mode

Поиск
Список
Период
Сортировка
Искать

Postgres: Starting Server in background mode

От:
CM J <postgres.newbie@gmail.com>
Дата:
Hi,

       To start the postgres server in background mode in windows, i executed the following command:

runas /user:postgres "D:\postgres_new\pgsql\bin\pg_ctl.exe -W start -D D:\postgres_new\pgsql\data -l D:\postgres_new\pgsql\data\logfile"

         The postgres starts up all fine and logs get redirected.However, a command window gets opened which says "server starting...". How do i disable this command window ?

Thanks !

Re: Postgres: Starting Server in background mode

От:
Craig Ringer <craig@postnewspapers.com.au>
Дата:
CM J wrote:
> Hi,
> 
>        To start the postgres server in background mode in windows, i
> executed the following command:
> 
> *runas /user:postgres "D:\postgres_new\pgsql\bin\pg_ctl.exe -W start -D
> D:\postgres_new\pgsql\data -l D:\postgres_new\pgsql\data\logfile"*
> 
>          The postgres starts up all fine and logs get redirected.However, a
> command window gets opened which says "server starting...". How do i disable
> this command window ?

Run Pg as a service, and use the "net" command or the "services.msc"
snapin to start/stop the service.

The GUI installer sets Pg up as a service by default. Why not use that?

--
Craig Ringer

Re: Postgres: Starting Server in background mode

От:
CM J <postgres.newbie@gmail.com>
Дата:
Hi,

     I do not want start postgres as a service.Postgres will bundled along with my application and i am only looking at starting it only from cmd line.If there are any options to disable this cmd window which appears after executing the "pg_ctl.exe start", that would be great !

Thanks.

On Thu, Apr 9, 2009 at 3:52 PM, Craig Ringer <craig@postnewspapers.com.au> wrote:
CM J wrote:
> Hi,
>
>        To start the postgres server in background mode in windows, i
> executed the following command:
>
> *runas /user:postgres "D:\postgres_new\pgsql\bin\pg_ctl.exe -W start -D
> D:\postgres_new\pgsql\data -l D:\postgres_new\pgsql\data\logfile"*
>
>          The postgres starts up all fine and logs get redirected.However, a
> command window gets opened which says "server starting...". How do i disable
> this command window ?

Run Pg as a service, and use the "net" command or the "services.msc"
snapin to start/stop the service.

The GUI installer sets Pg up as a service by default. Why not use that?

--
Craig Ringer

Re: Postgres: Starting Server in background mode

От:
Sam Mason <sam@samason.me.uk>
Дата:
On Thu, Apr 09, 2009 at 04:53:06PM +0530, CM J wrote:
>      I do not want start postgres as a service.Postgres will bundled along
> with my application and i am only looking at starting it only from cmd
> line.If there are any options to disable this cmd window which appears after
> executing the "pg_ctl.exe start", that would be great !

I think you can pass options to CreateProcess that will cause it to
"hide" the window; not sure if this is what you want but I've not
programmed under Windows for a long time so can't suggest more.

-- 
  Sam  http://samason.me.uk/

Re: Postgres: Starting Server in background mode

От:
Thomas Kellerer <spam_eater@gmx.net>
Дата:
CM J, 09.04.2009 13:23:
>      I do not want start postgres as a service.Postgres will bundled 
> along with my application and i am only looking at starting it only from 
> cmd line.If there are any options to disable this cmd window which 
> appears after executing the "pg_ctl.exe start", that would be great !
> 
> Thanks.
If you are running this from a batch file, try

start pg_ctl ....

That might get rid of the window (you'll still have the initial Window that is shown when you run the batch file, but that is then closed) 

Thomas

Re: Postgres: Starting Server in background mode

От:
Tino Wildenhain <tino@wildenhain.de>
Дата:
CM J wrote:
> Hi,
> 
>      I do not want start postgres as a service.Postgres will bundled 
> along with my application and i am only looking at starting it only from 
> cmd line.If there are any options to disable this cmd window which 
> appears after executing the "pg_ctl.exe start", that would be great !

The problem here is, Postgres is not an embedded database but really a
database management system. Therefore trying to bundle it with a desktop
application will usually cause more headaches. I'd suggest installing
Postgres as central service (as you know with web servers, application 
servers, mail servers... ) and connect your clients to it or use a
desktop/linkable database for example firebird or whatever.

Regards
Tino

Re: Postgres: Starting Server in background mode

От:
Craig Ringer <craig@postnewspapers.com.au>
Дата:
Tino Wildenhain wrote:

> The problem here is, Postgres is not an embedded database but really a
> database management system. Therefore trying to bundle it with a desktop
> application will usually cause more headaches. I'd suggest installing
> Postgres as central service

Note that Windows is designed to allow applications to create services,
start them, stop them, etc. You should have *NO* problems having your
application install PostgreSQL as a service, and start/stop it on
demand. You can do this through the command line (net.exe), the Services
snap-in (services.msc), or via Win32 API calls from your application.

Doing anything else is trying to re-invent the Windows service mechanism
- poorly - and is really just NOT a good idea.

--
Craig Ringer

Re: Postgres: Starting Server in background mode

От:
Scott Marlowe <scott.marlowe@gmail.com>
Дата:
On Thu, Apr 9, 2009 at 8:18 PM, Craig Ringer
 wrote:
> Tino Wildenhain wrote:
>
>> The problem here is, Postgres is not an embedded database but really a
>> database management system. Therefore trying to bundle it with a desktop
>> application will usually cause more headaches. I'd suggest installing
>> Postgres as central service
>
> Note that Windows is designed to allow applications to create services,
> start them, stop them, etc. You should have *NO* problems having your
> application install PostgreSQL as a service, and start/stop it on
> demand. You can do this through the command line (net.exe), the Services
> snap-in (services.msc), or via Win32 API calls from your application.

Note that if one is going to do this, it's probably a good idea to
install your private pgsql into a different default directory and have
it answer on a different port than the 5432 one, so that if the user
has or will install their own pgsql version your customer version
won't get in the way.
FAQ