-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* lib/parkplace/torrent.rb: removed all internal seeder code.
* lib/parkplace.rb: see below. * bin/parkplace: moved a bunch of the repetitive config stuff to the ParkPlace module. * bin/parkseed: external seeder tool. * Rakefile: include parkseed.
- Loading branch information
_why
committed
May 3, 2006
1 parent
04b54cc
commit 9052542
Showing
5 changed files
with
125 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/usr/bin/env ruby | ||
$:.unshift "./lib" | ||
require 'optparse' | ||
require 'parkplace' | ||
require 'stringio' | ||
|
||
options = ParkPlace.options | ||
options.seed_host = "127.0.0.1" | ||
options.seed_port = 3003 | ||
|
||
opts = OptionParser.new do |opts| | ||
opts.banner = "Usage: parkseed [options] [host] [port]" | ||
opts.separator "Default host is #{options.seed_host}, default port is #{options.seed_port}." | ||
|
||
opts.separator "" | ||
opts.separator "Specific options:" | ||
|
||
opts.on("-d", "--directory DIRECTORY", | ||
"Park Place directory (defaults to #{options.parkplace_dir || 'None'})") do |d| | ||
options.parkplace_dir = d | ||
end | ||
|
||
opts.on("-D", "--[no-]daemon", "Daemon mode") do |d| | ||
options.daemon = d | ||
end | ||
|
||
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v| | ||
options.verbose = v | ||
end | ||
|
||
opts.separator "" | ||
opts.separator "Common options:" | ||
|
||
opts.on_tail("-h", "--help", "Show this message") do | ||
puts opts | ||
exit | ||
end | ||
|
||
# Another typical switch to print the version. | ||
opts.on_tail("--version", "Show version") do | ||
puts ParkPlace::VERSION | ||
exit | ||
end | ||
end | ||
|
||
opts.parse! ARGV | ||
options.seed_host = ARGV[0] if ARGV[0] | ||
options.seed_port = ARGV[1].to_i if ARGV[1] | ||
ParkPlace.config(options) | ||
|
||
ParkPlace::Models::Base.establish_connection(options.database) | ||
ParkPlace::Models::Base.logger = Logger.new('camping.log') if $DEBUG | ||
ParkPlace.create | ||
|
||
server = RubyTorrent::Server.new(options.seed_host, options.seed_port).start | ||
loop do | ||
ParkPlace::Models::Torrent.find(:all, :include => :bit).each do |trnt| | ||
mi = RubyTorrent::MetaInfo.from_stream(StringIO.new(trnt.metainfo)) | ||
bit = trnt.bit | ||
unless server.instance_variable_get("@controllers").has_key? mi.info.sha1 | ||
begin | ||
puts "SEEDING #{bit.name}" | ||
server.add_torrent(mi, RubyTorrent::Package.new(mi, bit.fullpath)) | ||
rescue Exception => e | ||
puts "#{e.class}: #{e.message}" | ||
end | ||
end | ||
end | ||
sleep 2.minutes | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters