Re: Why not to use 'pg_ctl start -D ../data' to register posgtresql windows service

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: YuanyuanLiu <liuyuanyuangogo(at)gmail(dot)com>
Cc: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Why not to use 'pg_ctl start -D ../data' to register posgtresql windows service
Date: 2015-11-02 06:30:55
Message-ID: CAB7nPqSHNHiUDCq3n_f15PUL9_aYN9qqcYioy9ca66bb7fCm+A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Nov 2, 2015 at 2:54 PM, YuanyuanLiu <liuyuanyuangogo(at)gmail(dot)com> wrote:
> Nowadays, I always got problem about postgresql windows service.
> I find, postgresql usually use the following command to register windows
> services:
> /"D:\Program Files (x86)\PostgreSQL\9.4\bin\pg_ctl.exe" runservice -N
> "postgresql-9.4" -D "D:\Program Files (x86)\PostgreSQL\9.4\data" -w/
> But this command always failed, beacause of user privilege, just as a
> topic described:
> http://postgresql.nabble.com/pg-ctl-could-not-start-service-quot-pgsql-8-2-quot-error-code-1063-td1880801.html#a1880802
> While 'pg_ctl start -D ../data' works well, why not to use this command to
> register postgresql windows service? why to use 'pg_ctl runservice -N "psql"
> -D ".../data"' ? This is really confused me when I use postgresql in
> windows.

runservice is not a command that is aimed to be run manually, and
that's what your link above refers to. A service should be registered
using register, then you should use sc to start the service if you are
doing it manually (you may do it automatically that's the default
behavior then there is no need to use sc):
pg_ctl register -N pg_service_name -D %PGDATA% -S demand
sc start pg_service_name

Now we could make the code more complicated in the start path to
support that. And some users may want to be able to start a server on
Windows without having to set up a service that lasts only for the
time of a session. For example sometimes I do so for testing purposes.
So that's quite handy to not rely on the Windows SCM in this case.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2015-11-02 06:56:59 Re: BUG #13741: vacuumdb does not accept valid password
Previous Message Michael Paquier 2015-11-02 06:19:05 Re: remove wal_level archive