FS#4694 - rsync startup script errors

Attached to Project: Arch Linux
Opened by Erwin Van de Velde (evdvelde) - Wednesday, 24 May 2006, 12:50 GMT
Last edited by Eric Belanger (Snowman) - Sunday, 16 December 2007, 22:43 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Eric Belanger (Snowman)
Architecture All
Severity Medium
Priority Normal
Reported Version 0.7.1 Noodle
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

The rsync startup script fails to restart or stop the daemon because of missing pid file. The file /var/run/rsyncd.pid is never created.
This task depends upon

Closed by  Eric Belanger (Snowman)
Sunday, 16 December 2007, 22:43 GMT
Reason for closing:  Fixed
Comment by Judd Vinet (judd) - Wednesday, 31 May 2006, 21:36 GMT
The problem is that rsync won't write it out its own pidfile, so we have to. But we can't reliably use pidof(1) like we do with most daemons, since the rsync binary is both the client and the server binary in one.

Example scenario:

You run an rsync to mirror some files on a remote server. While that's going on, you start up your rsync server with "/etc/rc.d/rsync start". Now the rc.d/rsync script grabs the pid of the WRONG rsync binary and stores it in /var/run/rsync.pid. If you run "/etc/rc.d/rsync stop" it will kill the wrong rsync binary.

Anyone know if bash has a special parameter that returns the PID of the last-executed command? I seem to remember it having something like that...
Comment by Jan de Groot (JGC) - Wednesday, 31 May 2006, 22:01 GMT
Bash can retrieve the PID of the last executed background process with the $! variable. The problem with that is that rsync will fork and exit, so the PID retrieved from that is not the actual PID of rsync.
Comment by eliott (cactus) - Friday, 28 September 2007, 17:04 GMT
We could probably do something like..

pgrep -of "/usr/bin/rsync --daemon" > /var/run/rsyncd.pid

The "-o" should return the oldest started instance pid.
Hopefully that would be the session leader (ppid).
Comment by Dale Blount (dale) - Wednesday, 05 December 2007, 14:46 GMT
I've also seen issues where /var/run/daemons/rsyncd wasn't deleted on stop and thus wouldn't start again until that file was manually removed. Not sure if it's related or not.
Comment by Aaron Griffin (phrakture) - Wednesday, 05 December 2007, 22:06 GMT
Using pgrep might be the wisest idea here, seeing that we need to look for the "--daemon" arg
Comment by Eric Belanger (Snowman) - Sunday, 09 December 2007, 02:47 GMT
I just uploaded rsync 2.6.9-4 in testing. I've used the pgrep suggestion to fix the PID issue and added a 'sleep 1' in the daemon's restart function which seems to fix Dale's problem. Report any success/failures.

Loading...