Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 Oct 2011 14:25:07 +0200 (CEST)
From:      bayle.philippe@gmail.com
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/161334: [patch] monit rc.d script is run too soon
Message-ID:  <201110061225.p96CP7YG009102@erebor.fr>
Resent-Message-ID: <201110061230.p96CUBA4034836@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Oct 06 12:30:10 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     P. Bayle
>Release:        FreeBSD 8.2-RELEASE-p3 amd64
>Organization:
none
>Environment:
System: FreeBSD plop.fr 8.2-RELEASE-p3 FreeBSD 8.2-RELEASE-p3 #0: Tue Sep 27 18:45:57 UTC 2011 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC amd64

>Description:
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)

>How-To-Repeat:
Difficult to reproduce consistently, as the race conditions depends in a combination of several services/configurations.

>Fix:
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
-# REQUIRE: NETWORKING SERVERS
-# BEFORE: DAEMON
+# REQUIRE: LOGIN
 # KEYWORD: shutdown
 

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201110061225.p96CP7YG009102>