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

From Michael Paquier
Subject Re: Why not to use 'pg_ctl start -D ../data' to register posgtresql windows service
Date
Msg-id CAB7nPqSHNHiUDCq3n_f15PUL9_aYN9qqcYioy9ca66bb7fCm+A@mail.gmail.com
Whole thread Raw
In response to Why not to use 'pg_ctl start -D ../data' to register posgtresql windows service  (YuanyuanLiu <liuyuanyuangogo@gmail.com>)
Responses Re: Why not to use 'pg_ctl start -D ../data' to register posgtresql windows service  (YuanyuanLiu <liuyuanyuangogo@gmail.com>)
List pgsql-hackers
On Mon, Nov 2, 2015 at 2:54 PM, YuanyuanLiu <liuyuanyuangogo@gmail.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



pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: remove wal_level archive
Next
From: Michael Paquier
Date:
Subject: Re: Re: BUG #13685: Archiving while idle every archive_timeout with wal_level hot_standby