Postgres: Starting Server in background mode

Started by CM Jabout 17 years ago8 messagesgeneral
Jump to latest
#1CM 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 !

#2Craig Ringer
craig@2ndquadrant.com
In reply to: CM J (#1)
Re: Postgres: Starting Server in background mode

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

#3CM J
postgres.newbie@gmail.com
In reply to: Craig Ringer (#2)
Re: Postgres: Starting Server in background mode

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:

Show quoted text

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

#4Sam Mason
sam@samason.me.uk
In reply to: CM J (#3)
Re: Postgres: Starting Server in background mode

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/

#5Thomas Kellerer
spam_eater@gmx.net
In reply to: CM J (#3)
Re: Postgres: Starting Server in background mode

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

#6Tino Wildenhain
tino@wildenhain.de
In reply to: CM J (#3)
Re: Postgres: Starting Server in background mode

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

#7Craig Ringer
craig@2ndquadrant.com
In reply to: Tino Wildenhain (#6)
Re: Postgres: Starting Server in background mode

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

#8Scott Marlowe
scott.marlowe@gmail.com
In reply to: Craig Ringer (#7)
Re: Postgres: Starting Server in background mode

On Thu, Apr 9, 2009 at 8:18 PM, Craig Ringer
<craig@postnewspapers.com.au> 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.