LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices



Reply
 
Search this Thread
Old 12-16-2007, 02:08 PM   #1
a550ee
LQ Newbie
 
Registered: Apr 2006
Posts: 16

Rep: Reputation: 0
Help to daemonize btaunchmany


Hello!
I want daemonize bittorrent downloader btlaunchmay to enable it to start on boot and download in background.
I've made bash script like this to set current dir and redirect output (/home/bittorrent/bin/btlaunchmany):
Code:
  1 #!/bin/bash
  2 PY=/home/dmitry/opt/bittorrent/bittorrent-3.4.2/btlaunchmany.py
  3 OUT=~/var/log/btlaunchmany.out
  4 ERR=~/var/log/btlaunchmany.err
  5 
  6 cd
  7 echo "[$(date)] Starting bittorrent" > ${OUT}
  8 echo "[$(date)] Starting bittorrent" > ${ERR}
  9 python ${PY} . \
 10     1>${OUT} 2>${ERR}
And following init.d script (/etc/init.d/btlaunchmany):
Code:
#!/bin/bash

USER=bittorrent
PID=/var/run/btlaunchmany.pid

case $1 in
	start)
	echo "Starting btlaunchmany"
	start-stop-daemon --start --quiet --background --make-pidfile \
		--pidfile ${PID} --exec /home/${USER}/bin/btlaunchmany \
        --chuid ${USER}:${USER} 
	exit $?
	;;
	stop)
	echo "Stopping btlaunchmany"
	start-stop-daemon --stop --quiet --pidfile ${PID}
	exit $?
	;;
	*)
	echo "Usage $0 start|stop"
	;;
esac
exit 1
to manage it all with sysv-rc-conf.

It starts nicely but after /etc/init.d/btlaunchmany stop python's process lives on and donwload continues.

How to arrange it all right way?
 
Old 12-16-2007, 04:13 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,785
Blog Entries: 54

Rep: Reputation: 2978Reputation: 2978Reputation: 2978Reputation: 2978Reputation: 2978Reputation: 2978Reputation: 2978Reputation: 2978Reputation: 2978Reputation: 2978Reputation: 2978
The PID of the process btlaunchmany.py is the child's $SID, so pgrepping with "-s PID of parent" should show them. If you fancy other peoples scripts this is what I found, looks good and well-documented: http://wiki.theory.org/BASH_script_t...nt_as_a_daemon
 
Old 12-18-2007, 03:50 PM   #3
a550ee
LQ Newbie
 
Registered: Apr 2006
Posts: 16

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by unSpawn View Post
The PID of the process btlaunchmany.py is the child's $SID, so pgrepping with "-s PID of parent" should show them.
I wonder why childs don't get killed when parent process dies. That's not a unix way

Quote:
Originally Posted by unSpawn View Post
That's AWESOME!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
kernel 2.6.1: driver compile err: daemonize() too few parameters qwijibow Linux - Software 0 01-21-2004 08:54 PM
A problem with serial port after adding daemonize code. Calvin Fang Linux - General 0 01-21-2004 05:15 PM


All times are GMT -5. The time now is 06:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration