ports/161334: [patch] monit rc.d script is run too soon

bayle.philippe at gmail.com bayle.philippe at gmail.com
Thu Oct 6 12:30:11 UTC 2011

>Number:         161334
>Category:       ports
>Synopsis:       [patch] monit rc.d script is run too soon
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Oct 06 12:30:10 UTC 2011
>Originator:     P. Bayle
>Release:        FreeBSD 8.2-RELEASE-p3 amd64
System: FreeBSD plop.fr 8.2-RELEASE-p3 FreeBSD 8.2-RELEASE-p3 #0: Tue Sep 27 18:45:57 UTC 2011 root at amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC amd64

With the current rc.d script for sysutils/monit (5.3_1), race conditions can frequently occur between monit actions and rc.d actions.
Results can be :
- services launched several times (frequently seen with MySQL)
- pid files inconsistent with real PID of services (frequently seen with lighttpd)
- owner/permission issues (frequently seen with the socket file /var/run/openldap/ldapi of OpenLDAP)

Difficult to reproduce consistently, as the race conditions depends in a combination of several services/configurations.

One way to avoid those problems is to disable monitored services in /etc/rc.conf and to configure Monit in order to launch them with the 'onestart' actions of rc.d scripts. This approach has some issues :
- rc.d scripts are not used in the way they were intended to be used anymore
- inconsistency in /etc/rc.conf (why would we put a line service_flags="-n foo" and not a line service_enable="YES"?)
- the launch of services becomes entirely dependent of a third-party package, meaning that the breakage of Monit would prevent the launch of monitored services. This is a very undesirable consequence when you want to use monit as a watchdog for critical services.

A better way to avoid those problems is to edit the rc.d script of Monit in order to make it run after the monitored services are launched by the normal rc.d operations. Hence the following patch :

--- /usr/local/etc/rc.d/monit.orig	2011-10-06 11:27:16.000000000 +0200
+++ /usr/local/etc/rc.d/monit	2011-10-06 11:27:36.000000000 +0200
@@ -4,8 +4,7 @@
 # PROVIDE: monit
 # KEYWORD: shutdown


More information about the freebsd-ports-bugs mailing list