Permalink
Browse files

server: some rebump, use threadpool etc

  • Loading branch information...
1 parent a0a07aa commit d405bf7851a6091e5955e1db2e2b313e754768c0 @meh committed Dec 16, 2011
Showing with 1,994 additions and 2,042 deletions.
  1. +18 −18 bin/failircd
  2. +3 −3 etc/failircd.yml
  3. +6 −6 failirc.gemspec
  4. +51 −52 lib/failirc/client.rb
  5. +321 −326 lib/failirc/common/extensions.rb
  6. +69 −69 lib/failirc/common/utils.rb
  7. +0 −41 lib/failirc/common/workers.rb
  8. +96 −97 lib/failirc/server.rb
  9. +63 −73 lib/failirc/server/dispatcher.rb
  10. +149 −141 lib/failirc/server/dispatcher/client.rb
  11. +72 −72 lib/failirc/server/dispatcher/server.rb
  12. +3 −3 lib/failirc/server/modules/autojoin.rb
  13. +2 −2 lib/failirc/server/modules/autotune.rb
  14. +4 −2 lib/failirc/server/modules/base.rb
  15. +7 −7 lib/failirc/server/modules/base/action.rb
  16. +139 −139 lib/failirc/server/modules/base/channel.rb
  17. +6 −6 lib/failirc/server/modules/base/channel/extensions.rb
  18. +16 −16 lib/failirc/server/modules/base/channel/modifier.rb
  19. +34 −34 lib/failirc/server/modules/base/channel/topic.rb
  20. +35 −35 lib/failirc/server/modules/base/channels.rb
  21. +78 −78 lib/failirc/server/modules/base/client.rb
  22. +8 −8 lib/failirc/server/modules/base/clients.rb
  23. +112 −112 lib/failirc/server/modules/base/errors.rb
  24. +55 −55 lib/failirc/server/modules/base/flags.rb
  25. +38 −38 lib/failirc/server/modules/base/incoming.rb
  26. +25 −25 lib/failirc/server/modules/base/powers.rb
  27. +128 −128 lib/failirc/server/modules/base/responses.rb
  28. +21 −21 lib/failirc/server/modules/base/server.rb
  29. +21 −21 lib/failirc/server/modules/base/support.rb
  30. +66 −66 lib/failirc/server/modules/base/user.rb
  31. +6 −6 lib/failirc/server/modules/base/user/can.rb
  32. +3 −3 lib/failirc/server/modules/base/user/extensions.rb
  33. +61 −61 lib/failirc/server/modules/base/user/level.rb
  34. +53 −53 lib/failirc/server/modules/base/users.rb
  35. +7 −8 lib/failirc/server/modules/firewall.rb
  36. +25 −25 lib/failirc/server/modules/reupload.rb
  37. +13 −13 lib/failirc/server/modules/shorten.rb
  38. +3 −3 lib/failirc/version.rb
  39. +177 −176 utils/stress.rb
View
@@ -24,38 +24,38 @@ require 'failirc/server'
require 'getoptlong'
args = GetoptLong.new(
- ['--version', '-v', GetoptLong::NO_ARGUMENT],
- ['--verbose', '-V', GetoptLong::NO_ARGUMENT],
- ['--config', '-f', GetoptLong::REQUIRED_ARGUMENT]
+ ['--version', '-v', GetoptLong::NO_ARGUMENT],
+ ['--verbose', '-V', GetoptLong::NO_ARGUMENT],
+ ['--config', '-f', GetoptLong::REQUIRED_ARGUMENT]
)
options = {
- :verbose => false,
- :config => '/etc/failircd.conf',
+ :verbose => false,
+ :config => '/etc/failircd.conf',
}
args.each {|option, value|
- case option
- when '--version'
- puts "Fail IRCd #{IRC.version}"
- exit 0
+ case option
+ when '--version'
+ puts "Fail IRCd #{IRC.version}"
+ exit 0
- when '--verbose'
- options[:verbose] = true
+ when '--verbose'
+ options[:verbose] = true
- when '--config'
- options[:config] = value
- end
+ when '--config'
+ options[:config] = value
+ end
}
ircd = IRC::Server.new(options[:config])
[:INT, :KILL].each {|sig|
- trap sig.to_s do
- puts 'FailIRC stopping, bye'
+ trap sig.to_s do
+ puts 'FailIRC stopping, bye'
- ircd.stop
- end
+ ircd.stop
+ end
}
ircd.start
View
@@ -11,7 +11,7 @@ server:
timeout: 15
- workers: 2 .. 4
+ workers: 4
operators:
- mask: "meh!*@*"
@@ -25,15 +25,15 @@ modules:
Welcome to a fail IRC.
ping timeout: 60
- allowed nick: "nick.match(/^[0-9A-Za-z_\[\]\{\}\|\^`\-\\=\.]{1,23}$/)"
+ allowed nick: 'nick.match(/^[0-9A-Za-z_\[\]\{\}\|\^`\-\\=\.]{1,23}$/)'
messages:
part: "#{message}"
version: "#{server.modules}"
quit: "Quit: #{message}"
kill: "Killed by #{sender.nick}: #{message.empty? ? 'No reason' : message}"
- autotune:
+ autotune:
minimum: 10
rate: 10
View
@@ -14,10 +14,10 @@ Gem::Specification.new {|s|
s.executables = ['failircd', 'failbot']
s.has_rdoc = true
- s.add_dependency('openssl-nonblock')
- s.add_dependency('versionub')
- s.add_dependency('actionpool')
- s.add_dependency('memoized')
- s.add_dependency('refining')
- s.add_dependency('refr')
+ s.add_dependency 'openssl-nonblock'
+ s.add_dependency 'versionub'
+ s.add_dependency 'threadpool'
+ s.add_dependency 'call-me'
+ s.add_dependency 'refining'
+ s.add_dependency 'refr'
}
View
@@ -20,7 +20,6 @@
require 'failirc/version'
require 'failirc/common/utils'
require 'failirc/common/events'
-require 'failirc/common/workers'
require 'failirc/common/modules'
require 'failirc/common/modes'
require 'failirc/common/mask'
@@ -30,57 +29,57 @@
module IRC
class Client
- extend Forwardable
-
- attr_reader :options, :dispatcher, :created_on
-
- def_delegators :@dispatcher, :connect, :running?
- def_delegators :@events, :register, :dispatch, :observe, :fire, :hook
- def_delegators :@workers, :do
- def_delegators :@modules, :load
-
- def initialize (options={})
- @options = HashWithIndifferentAccess.new(options)
-
- @dispatcher = Dispatcher.new(self)
- @events = Events.new(self)
- @workers = Workers.new(self)
- @modules = Modules.new(self, '/failirc/client/modules')
-
- if @options[:modules]
- @options[:modules].each {|name, data|
- begin
- mod = @modules.load(name, data)
-
- if mod
- mod.define_singleton_method :client do
- self
- end
-
- hook mod
-
- IRC.debug "#{name} loaded"
- else
- IRC.debug "#{name} had some errors"
- end
- rescue LoadError
- IRC.debug "#{name} not found"
- end
- }
- end
- end
-
- def start
- fire :start, self
-
- @dispatcher.start
- end
-
- def stop
- fire :stop, self
-
- @dispatcher.stop
- end
+ extend Forwardable
+
+ attr_reader :options, :dispatcher, :created_on
+
+ def_delegators :@dispatcher, :connect, :running?
+ def_delegators :@events, :register, :dispatch, :observe, :fire, :hook
+ def_delegators :@pool, :do
+ def_delegators :@modules, :load
+
+ def initialize (options={})
+ @options = HashWithIndifferentAccess.new(options)
+
+ @dispatcher = Dispatcher.new(self)
+ @events = Events.new(self)
+ @pool = ThreadPool.new
+ @modules = Modules.new(self, '/failirc/client/modules')
+
+ if @options[:modules]
+ @options[:modules].each {|name, data|
+ begin
+ mod = @modules.load(name, data)
+
+ if mod
+ mod.define_singleton_method :client do
+ self
+ end
+
+ hook mod
+
+ IRC.debug "#{name} loaded"
+ else
+ IRC.debug "#{name} had some errors"
+ end
+ rescue LoadError
+ IRC.debug "#{name} not found"
+ end
+ }
+ end
+ end
+
+ def start
+ fire :start, self
+
+ @dispatcher.start
+ end
+
+ def stop
+ fire :stop, self
+
+ @dispatcher.stop
+ end
end
end
Oops, something went wrong.

0 comments on commit d405bf7

Please sign in to comment.