/[pupa]/bugcomm/server/bts/system.rb
ViewVC logotype

Diff of /bugcomm/server/bts/system.rb

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by okuji, Fri Aug 9 18:08:25 2002 UTC revision 1.4 by okuji, Sat Aug 10 12:02:16 2002 UTC
# Line 21  Line 21 
21  require 'getoptlong'  require 'getoptlong'
22    
23  require 'bts/config'  require 'bts/config'
24    require 'bts/exception'
25    require 'bts/session'
26    
27  module BTS  module BTS
28        
# Line 65  module BTS Line 67  module BTS
67            puts "bugcommd (BugCommunicator #{@version})"            puts "bugcommd (BugCommunicator #{@version})"
68            exit 0            exit 0
69          when '--verbose'          when '--verbose'
70            @@verbosity.succ!            @@verbosity += 1
71          when '--config'          when '--config'
72            @config_file = arg            @config_file = arg
73          when '--log'          when '--log'
# Line 98  module BTS Line 100  module BTS
100    
101        @config = Config.new(@config_file)        @config = Config.new(@config_file)
102                
103          @socket = TCPServer.open(@config.server_port)
104          at_exit { @socket.close }
105          
106        if @log_file.nil? and @daemonized        if @log_file.nil? and @daemonized
107          require 'syslog'          require 'syslog'
108          @@log = Syslog.open('bugcommd',          @@log = Syslog.open('bugcommd',
# Line 159  module BTS Line 164  module BTS
164          $stderr.close          $stderr.close
165        end        end
166    
167        Thread.start do        begin
168          $SAFE = 2          Thread.start do
169          main()            $SAFE = 2
170        end.join            main()
171            end.join
172          rescue SignalException, Interrupt, ScriptError, NoMemoryError,
173              StandardError, BugCommError => e
174            @@log.err("%s", e.message)
175            @@log.err("%s", e.backtrace.join("\n"))
176            exit(1)
177          end
178      end      end
179    
180      def main      def main
181          while true
182            Thread.start(Session.new(@socket.accept, @config)) do |session|
183              begin
184                session.run
185              rescue ScriptError, NoMemoryError, StandardError, BugCommError => e
186                @@log.err("%s", e.message)
187                @@log.err("%s", e.backtrace.join("\n"))
188              ensure
189                session.close
190              end
191            end
192          end
193      end      end
194      private :main      private :main
195    end    end

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26