Running More Than One Instance Of A Service

I use sysutils/apcupsd to monitor a few different APC UPS units. I want to start three different instances of the apcupsd service, each using a different config file.

The services all start on boot, no problem there, but the pid files are not being written correctly. The only pid file is /var/run/apcupsd and it contains the pid for the most recently started service (the last pid). So, while the services start OK, I am unable to stop or restart them, because the pids don't exist.

What am I missing?

Here's what I have:

/etc/rc.conf
Code:
#
#	APC UPS
#
apcupsd0_enable="YES"
apcupsd0_pidfile="/var/run/apcupsd0.pid"
apcupsd0_lockfile="/var/spool/lock/apcupsd0.lock"
apcupsd0_flags="-f /usr/local/etc/apcupsd/apcupsd0.conf"

apcupsd1_enable="YES"
apcupsd1_pidfile="/var/run/apcupsd1.pid"
apcupsd1_lockfile="/var/spool/lock/apcupsd1.lock"
apcupsd1_flags="-f /usr/local/etc/apcupsd/apcupsd1.conf"

apcupsd2_enable="YES"
apcupsd2_pidfile="/var/run/apcupsd2.pid"
apcupsd2_lockfile="/var/spool/lock/apcupsd2.lock"
apcupsd2_flags="-f /usr/local/etc/apcupsd/apcupsd2.conf"

/usr/local/etc/rc.d/apcupsd2
Code:
#!/bin/sh
#
# $FreeBSD: ports/sysutils/apcupsd/files/apcupsd.in,v 1.5 2012/01/14 08:56:56 dougb Exp $
#
# PROVIDE: apcupsd
# REQUIRE: SERVERS
# BEFORE: DAEMON
# KEYWORD: shutdown
#
# Add the following line to /etc/rc.conf[.local] to enable apcupsd
#
# apcupsd_enable (bool):	Set to "NO" by default.
#				Set it to "YES" to enable apcupsd.
# apcupsd_args (str):		Custom additional arguments to be passed
#				to apcupsd (default empty).
#

. /etc/rc.subr

name="apcupsd2"
rcvar=apcupsd2_enable

load_rc_config $name

: ${apcupsd2_enable="NO"}
: ${apcupsd2_flags="--kill-on-powerfail"}
: ${apcupsd2_pidfile="/var/run/apcupsd2.pid"}
: ${apcupsd2_lockfile="/var/spool/lock/apcupsd2.lock"}

pidfile="/var/run/apcupsd2.pid"
required_files="/usr/local/etc/apcupsd/apcupsd2.conf"
command="/usr/local/sbin/apcupsd"

run_rc_command "$1"

Thanks!
 
Back
Top