Thread: repmgr.service

repmgr.service

From
Justin King
Date:
Please modify the repmgr-9.x.service files for the packages.

The service files currently have:

ExecStop=/usr/bin/kill -TERM ${PIDFILE}
ExecReload=/usr/bin/kill -HUP ${PIDFILE}

/bin/kill does not accept files, you may be thinking of /bin/pkill -f 

Replace them with:

ExecStop=/usr/bin/kill -TERM $MAINPID
ExecReload=/usr/bin/kill -HUP $MAINPID

$MAINPID is a special systemd provided variable that references the known PID of the process 

And add the following under the [Service] section:

PIDFile=/var/run/repmgr/repmgrd-9.x.pid

This prevents systemd from guessing what the PID is and being wrong when Type=forking 

As it stands now `systemctl stop repmgrd` and `systemctl reload repmgrd` will always fail.

Justin

Re: repmgr.service

From
Martín Marqués
Date:
Hi,

I see this hasn't been committed yet into the pgrpms git repo.

Is it under review? If so I can say the changes are good, and if needed
I can send over a patch for easy applying.

Regards,


El 13/11/15 a las 22:59, Justin King escribió:
> Please modify the repmgr-9.x.service files for the packages.
>
> The service files currently have:
>
>     ExecStop=/usr/bin/kill -TERM ${PIDFILE}
>     ExecReload=/usr/bin/kill -HUP ${PIDFILE}
>
>
> /bin/kill does not accept files, you may be thinking of /bin/pkill -f
>
> Replace them with:
>
>     ExecStop=/usr/bin/kill -TERM $MAINPID
>     ExecReload=/usr/bin/kill -HUP $MAINPID
>
>
> $MAINPID is a special systemd provided variable that references the
> known PID of the process
>
> And add the following under the [Service] section:
>
>     PIDFile=/var/run/repmgr/repmgrd-9.x.pid
>
>
> This prevents systemd from guessing what the PID is and being wrong when
> Type=forking
>
> As it stands now `systemctl stop repmgrd` and `systemctl reload repmgrd`
> will always fail.
>
> Justin


--
Martín Marqués                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


Re: repmgr.service

From
Jeff Frost
Date:
Sorry for the slow reply on this.

We did make some changes recently, but it seems this was not one of them.

A patch would definitely speed us up and would be most welcome!


On Dec 17, 2015, at 12:25 PM, Martín Marqués <martin@2ndquadrant.com> wrote:

Hi,

I see this hasn't been committed yet into the pgrpms git repo.

Is it under review? If so I can say the changes are good, and if needed
I can send over a patch for easy applying.

Regards,


El 13/11/15 a las 22:59, Justin King escribió:
Please modify the repmgr-9.x.service files for the packages.

The service files currently have:

   ExecStop=/usr/bin/kill -TERM ${PIDFILE}
   ExecReload=/usr/bin/kill -HUP ${PIDFILE}


/bin/kill does not accept files, you may be thinking of /bin/pkill -f

Replace them with:

   ExecStop=/usr/bin/kill -TERM $MAINPID
   ExecReload=/usr/bin/kill -HUP $MAINPID


$MAINPID is a special systemd provided variable that references the
known PID of the process

And add the following under the [Service] section:

   PIDFile=/var/run/repmgr/repmgrd-9.x.pid


This prevents systemd from guessing what the PID is and being wrong when
Type=forking

As it stands now `systemctl stop repmgrd` and `systemctl reload repmgrd`
will always fail.

Justin


--
Martín Marqués                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


--
Sent via pgsql-pkg-yum mailing list (pgsql-pkg-yum@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-pkg-yum

---
Jeff Frost <jeff@pgexperts.com>
Director, PostgreSQL Experts, Inc.
Phone: 1-888-PG-EXPRT x506
FAX: 415-762-5122




Re: repmgr.service

From
Martín Marqués
Date:
El 22/12/15 a las 23:52, Jeff Frost escribió:
> Sorry for the slow reply on this.
>
> We did make some changes recently, but it seems this was not one of them.
>
> A patch would definitely speed us up and would be most welcome!

I'm working on a patch against the pgrpms repo and I see that there are
systemd service files for EL-5.

For example, check ./9.4/repmgr/EL-5/repmgr-9.4.service

Any reason for that?

--
Martín Marqués                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


Re: repmgr.service

From
Devrim Gündüz
Date:
Hi,

Recent spec file is a unified one, which can be used on both old and new distros -- so to keep branches the same, I committed same files to each distro.

Regards, Devrim

On December 30, 2015 8:09:32 PM GMT+02:00, "Martín Marqués" <martin@2ndquadrant.com> wrote:
El 22/12/15 a las 23:52, Jeff Frost escribió:
Sorry for the slow reply on this.

We did make some changes recently, but it seems this was not one of them.

A patch would definitely speed us up and would be most welcome!

I'm working on a patch against the pgrpms repo and I see that there are
systemd service files for EL-5.

For example, check ./9.4/repmgr/EL-5/repmgr-9.4.service

Any reason for that?

--
Sent from my Android device with K-9 Mail. Please excuse my brevity.

Re: repmgr.service

From
Martín Marqués
Date:
Hi Devrim,

2015-12-30 15:18 GMT-03:00 Devrim Gündüz <devrim@gunduz.org>:
> Hi,
>
> Recent spec file is a unified one, which can be used on both old and new
> distros -- so to keep branches the same, I committed same files to each
> distro.

Yes, I've seen the spec, but didn't realize there would be useless files around.

BTW, why not unify everything in one directory for all distros and
versions? It would make it much easier to maintain, and especially to
patch (like what I'm doing now)

Regards,

--
Martín Marqués                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


Re: repmgr.service

From
Devrim Gündüz
Date:
Hi,

That makes the build process easier. We have separate VMs for each combination. When we use separate dirs, we can build packages with a single command.

I inherited this from Fedora's build system, btw.

Regards, Devrim

On December 30, 2015 8:50:20 PM GMT+02:00, "Martín Marqués" <martin@2ndquadrant.com> wrote:
Hi Devrim,

2015-12-30 15:18 GMT-03:00 Devrim Gündüz <devrim@gunduz.org>:
Hi,

Recent spec file is a unified one, which can be used on both old and new
distros -- so to keep branches the same, I committed same files to each
distro.

Yes, I've seen the spec, but didn't realize there would be useless files around.

BTW, why not unify everything in one directory for all distros and
versions? It would make it much easier to maintain, and especially to
patch (like what I'm doing now)

Regards,

--
Sent from my Android device with K-9 Mail. Please excuse my brevity.

Re: repmgr.service

From
Martín Marqués
Date:
El 30/12/15 a las 16:25, Devrim Gündüz escribió:
> Hi,
>
> That makes the build process easier. We have separate VMs for each
> combination. When we use separate dirs, we can build packages with a
> single command.

I still don't understand why separate dirs would have anything to do.

If you have one spec and one dir with everything needed for any distro,
you can just use the same directory and same spec for any build.

BTW, I'm sending a patch for the systemd bug in a separate mail any time
soon.

I have a few other patches (for the init script and for the spec file).
I'll send those later or next week.

--
Martín Marqués                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


Re: repmgr.service

From
Martín Marqués
Date:
El 22/12/15 a las 23:52, Jeff Frost escribió:
> Sorry for the slow reply on this.
>
> We did make some changes recently, but it seems this was not one of them.
>
> A patch would definitely speed us up and would be most welcome!

Promised patch. Let me know if there's something to fix.

Regards,

--
Martín Marqués                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Attachment

Re: repmgr.service

From
Martín Marqués
Date:
El 22/12/15 a las 23:52, Jeff Frost escribió:
> Sorry for the slow reply on this.
>
> We did make some changes recently, but it seems this was not one of them.
>
> A patch would definitely speed us up and would be most welcome!
>
>

This is another patch I had pending for a long time which adds some
improvements to the old sysV init scripts.

I'll try to roll the spec file patch.

--
Martín Marqués                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Attachment

Re: repmgr.service

From
Martín Marqués
Date:
El 22/12/15 a las 23:52, Jeff Frost escribió:
> Sorry for the slow reply on this.
>
> We did make some changes recently, but it seems this was not one of them.
>
> A patch would definitely speed us up and would be most welcome!

Last patch of the day. The one with changes to the spec file.

Please check them and if there's something to fix let me know and I'll
take care of it next week.

Regards, and happy new year!

--
Martín Marqués                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Attachment

Re: repmgr.service

From
Devrim GÜNDÜZ
Date:
Hi,

On Wed, 2015-12-30 at 18:59 -0300, Martín Marqués wrote:

> Last patch of the day. The one with changes to the spec file.
>
> Please check them and if there's something to fix let me know and
> I'll take care of it next week.

I checked this today. Some parts of this patch is already committed.
Why did you add postgres user with repmgr? That is done as a part of
PostgreSQL RPMs, which is a Requires: part.

Regards,
--
Devrim GÜNDÜZ
Principal Systems Engineer @ EnterpriseDB: http://www.enterprisedb.com
PostgreSQL Danışmanı/Consultant, Red Hat Certified Engineer
Twitter: @DevrimGunduz , @DevrimGunduzTR



Attachment

Re: repmgr.service

From
Devrim GÜNDÜZ
Date:
Hi,

On Wed, 2015-12-30 at 18:27 -0300, Martín Marqués wrote:
> This is another patch I had pending for a long time which adds some
> improvements to the old sysV init scripts.

Thanks for the patch! I applied this to 9.5 branch with some changes,
and built packages. 

Can you please check this commit, and let me know if you see any
issues?

http://git.postgresql.org/gitweb/?p=pgrpms.git;a=commit;h=bd9ecc3831f73c8f72e9dde8cb569fb81425ad4b


Thanks!

Regards,

--
Devrim GÜNDÜZ
Principal Systems Engineer @ EnterpriseDB: http://www.enterprisedb.com
PostgreSQL Danışmanı/Consultant, Red Hat Certified Engineer
Twitter: @DevrimGunduz , @DevrimGunduzTR



Attachment

Re: repmgr.service

From
Devrim GÜNDÜZ
Date:
Hi,

On Wed, 2015-12-30 at 17:40 -0300, Martín Marqués wrote:
> Promised patch. Let me know if there's something to fix.

I think this patch needs an update -- what is MAINPID variable? I don't
think it is defined elsewhere. Am I wrong?

Still, this patch already seems to be applied to 9.5. Can you please
confirm? If 9.5 branch looks good, I'll push it to other releases as
well.

Regards,
--
Devrim GÜNDÜZ
Principal Systems Engineer @ EnterpriseDB: http://www.enterprisedb.com
PostgreSQL Danışmanı/Consultant, Red Hat Certified Engineer
Twitter: @DevrimGunduz , @DevrimGunduzTR



Attachment

Re: repmgr.service

From
Martín Marqués
Date:
Hi,

2016-01-05 11:08 GMT-03:00 Devrim GÜNDÜZ <devrim@gunduz.org>:
>
> Hi,
>
> On Wed, 2015-12-30 at 18:59 -0300, Martín Marqués wrote:
>
>> Last patch of the day. The one with changes to the spec file.
>>
>> Please check them and if there's something to fix let me know and
>> I'll take care of it next week.
>
> I checked this today. Some parts of this patch is already committed.

Hum, I recall doing a git pull before applying the changes. Anyway, I
don't think I'll be able too go through the whole patching again now.
I can send you 1 patch for 1 file if that suffices.

> Why did you add postgres user with repmgr? That is done as a part of
> PostgreSQL RPMs, which is a Requires: part.

I was think what you meant with this, and now I understand. Yes,
adding the postgres user again is completely useless. My bad there.

We *do* want to use postgres instead of a separate repmgr OS user, as
we need this to be able to perform the promote and follow commands.

Regards,

--
Martín Marqués                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


Re: repmgr.service

From
Martín Marqués
Date:
Hi,

$MAINPID is a systemd special environment variable

http://www.freedesktop.org/software/systemd/man/systemd.service.html

====
One additional, special environment variable is set: if known,
$MAINPID is set to the main process of the daemon, and may be used for
command lines like the following:

/bin/kill -HUP $MAINPID
===

We tell systemd how to get the PID with PIDFile=

Regards,


2016-01-05 12:18 GMT-03:00 Devrim GÜNDÜZ <devrim@gunduz.org>:
>
> Hi,
>
> On Wed, 2015-12-30 at 17:40 -0300, Martín Marqués wrote:
>> Promised patch. Let me know if there's something to fix.
>
> I think this patch needs an update -- what is MAINPID variable? I don't
> think it is defined elsewhere. Am I wrong?
>
> Still, this patch already seems to be applied to 9.5. Can you please
> confirm? If 9.5 branch looks good, I'll push it to other releases as
> well.
>
> Regards,
> --
> Devrim GÜNDÜZ
> Principal Systems Engineer @ EnterpriseDB: http://www.enterprisedb.com
> PostgreSQL Danışmanı/Consultant, Red Hat Certified Engineer
> Twitter: @DevrimGunduz , @DevrimGunduzTR
>
>



--
Martín Marqués                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services