init script successfully triggers daemon process but doesn't create pid file -Deb7
I am trying to use an initscript to run some rsyncing via inotifywait. In true newbie style I have borrowed an initscript of the web and have edited the inputs to suit (though I have read over it to understand how it works).
All is well to the extent that when I start the machine under run levels 2 or 3 the daemon that I have written is indeed triggered as expected – I can verify that if I edit a file in one test folder, it gets rsynced instantly to another folder which is what the daemon is set up to acheive at the minute. The problem is that this script does not appear to be creating a pid file and hence I cannot stop the service by calling Code:
sudo /etc/init.d/websites_send_backups stop Quote:
Disclaimer – I’m fresh to shell scripting so all sorts of scripting errors could be under my nose without my necessarily being aware of them. This is on Debian Wheezy Release 7.4. What I have tried: • Reading the daemon log file (couldn’t even find a reference to website_send_backups), did a cat /var/log/daemon.log |grep website on it too to make sure. • Perusing various other log files just in case again nothing caught my eye. • Verified the daemon is truly responsible for triggering the inotifywait watch and therefore the initscript must be being invoked as expected by removing the website_send_backups using rc.update and rebooting – upon which as expected the rsyncing on close_write no longer occurs. • Run ps –ef|grep websites_send_backups and ps –ef|grep websites_send_backupsd to find out what processes have been spawned under that name (see below). • Checked the options provided by my initscript do indeed appear to be those specified in the manual. • :Alternating the ‘provides’ line between the daemon name and the initscript name - though I think that’s just what gets printed to the terminal and is therefore more or less irrelevant (just wanted to say I’d edited something since the problem really) . • Errmm...thats it. Thrown up my hands and started typing this post. Here’s my init-script and output of ps commands – please let me know if I can usefully post anything else. Code:
# Provides: websites_send_backupsd Output of command ps –ef |grep websites_send_backups psd: Quote:
Quote:
|
Errrm...ahem. I've now read the manual for the start stop daemon tool and it would seem that it doesn't actually create the pidfile unless you specify the -make-pidfile option. Ironic cheers all round. And even if you do use that option, it doesn't actually delete the pidfile when you use the stop command. Sorry, I kind of assumed that this kind of thing was being handled by the start-stop-daemon as default, though on reflection that is a silly assumption, particularly as my init script explicitly handles its removal rather than relying on the start stop daemon for that - I now realise that most processes handle their own pidfile creation and deletion.
However although my init script currently handles the deletion of the pidfile on successful stop, I'm guessing that getting the daemon itself to handle the creation and removal of its pid is the preferred option rather than relying on the start stop daemon and the initscript respectively as its more portable and more reliable. I don't know how exactly to grab the environment variable from the start-stop-daemon within the daemon itself, but I'll have a look into that.... I suppose I could grep for it or something but I imagine that is a horrible hack and there is a more elegant way... So I've solved my own non issue again. I'm having a great dialogue with myself here :) Its a real pity I can't mark my own comments as helpful and gain reputation I'd be a guru or something in no time (I'm joking of course, for those of you that may be serious minded - you never know). |
All times are GMT -5. The time now is 05:23 AM. |