multiple rsyncd daemons: init script

Matt McCutchen matt at mattmccutchen.net
Thu Dec 20 15:36:21 GMT 2007


On Wed, 2007-12-19 at 11:10 +0100, Johan Huysmans wrote: 
> I want to run 2 rsync daemons on my system. Each has its own 
> configuration file, and they are listening on a specific port.
> These 2 daemons are running perfectly but getting them started by 2 init 
> scripts is a bit more difficult.
> 
> The problem is that when stopping rsync you check the pid of rsync, 
> which results in both pids of the daemons.
> Off course i want the script to be very generic, meaning that they are 
> identical for both daemons, except the rsync options.
> But the script must also be used in a simple situation (= 1 rsync daemon 
> running on the system).
> 
> Does someone have such init script or ideas of how that should be build.
> 
> I'm trying using the functions provided by /etc/init.d/functions on a 
> centos system.
> This will check for the pid in /var/run/rsync.pid, but this doesn't work 
> nicely with multiple daemons.

Just use a different pid file for each daemon, perhaps
/var/run/rsync1.pid and /var/run/rsync2.pid .  Each daemon's
configuration file should specify the location of that daemon's pid
file.  Then, on the reasonable assumption that your CentOS init.d
functions work like my Fedora ones, it looks like each init script just
has to specify the appropriate pid file to killproc:

killproc -p /var/run/rsync1.pid rsync

The httpd init script has an example of this usage of killproc.

If you are unhappy with hard-coding a different pid file in each init
script: each script must know somehow which daemon configuration file it
is supposed to specify to rsync, so the scripts could parse the pid file
path out of the configuration file using sed.

Matt



More information about the rsync mailing list