- 论坛徽章:
- 0
|
是这样的,因为当时架设BT服务器,使用的是BitTorrent,为了满足自己的需要,就修改了两行代码,使得bttracker.py程序可以自动将PID写入'/var/run/bttrack.pid'中。
代码是正确的,所以我把它提交给了BitTorrent的官方邮件地址 'bugs@bittorrent.com',第二天我就收到了作者的回复。这是我发的邮件原文和他的回复,您看了就明白了:
Require a new feature -- Get bttrack.py's PID and write it to a file(/var/run/bttrack.pid).
A week ago,I installed BitTorrent on FreeBSD 5.4 as a BT server,but i wanna a shell script to start and
stop the tracker expediently,just like those scripts under '/usr/local/etc/rc.d/".
I wanna i can get the bttrack.py's PID from a file after it start,it make stop the server expediently.
So ,i modified the 'bttracker.py',added two lines to get the tracker's PID and wrote it to '/var/run/bttrack.py'.
It's dirty code :
=========== bttrack.py ================
- from sys import argv
- from BitTorrent.track import track
- import os # added
- if __name__ == '__main__':
- file('/var/run/bttrack.pid', 'w').write(str(os.getpid())) # added
- track(argv[1:])
复制代码
=====================================
and i wrote a shell script 'bttrack.sh ',put it under '/usr/local/etc/rc.d' :
============ bttrack.sh ===================
- #!/usr/local/bin/bash
- # Author : MichaelBibby ( michaelbibby # gmail.com )
- # Date : 2005/12/15
- # Purpose : To start '/usr/local/bin/bttrack.py' at system startup.
- BTTRACK='/usr/local/bin/bttrack.py'
- BTTRACK_PID_FILE='/var/run/bttrack.pid'
- BTTRACK_PID=$(cat $BTTRACK_PID_FILE)
- BTTRACK_ARGS='--port 6969 --dfile /var/log/bttrack/dlinfo --allowed_dir
- /home/torrents --show_infopage 0 --logfile /var/log/bttrack/bttrack.log'
- function USAGE()
- {
- echo -e "\n\t Usage : $0 [start|stop]"
- }
- # ---- Main ------
- if [ X$# == X0 ]
- then
- $BTTRACK $BTTRACK_ARGS &
- elif [ X$# == X1 ]
- then
- case $1 in
- start) echo -ne "Starting BT tracker ..."
- $BTTRACK $BTTRACK_ARGS &
- echo -ne "\t Done."
- ;;
- stop) echo -ne "Stop BT tracker ..."
- kill $BTTRACK_PID
- echo -ne "\t Done."
- ;;
- *) USAGE
- ;;
- esac
- else
- USAGE
- fi
- # ----- Done ----
复制代码
=======================================
这是作者Matt Chisholm的回复(邮件原件):
Thanks so much, this has been on our to-do list for a while. In order
for it to be included in BitTorrent, you'll have to agree to license
it under the BitTorrent Open Source License:
http://www.bittorrent.com/license/
and to assign copyright to BitTorrent. Is this ok?
Of course, we'll add your name to the credits too.
matt
因为这两行代码都是您的作品,所以如果您同意它的license的话,我可以代表您向他回复邮件表示同意。
[ 本帖最后由 MichaelBibby 于 2005-12-20 17:57 编辑 ] |
|