Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 75 lines (59 sloc) 1.813 kb
3696bcc Added readme.
Your Name authored
1 #!/usr/bin/env ruby
2 #
3 # Copyright (c) 2009 Carson McDonald
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License version 2
7 # as published by the Free Software Foundation.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 #
18
d6af898 Carson McDonald More refactoring.
authored
19 require 'hs_transfer'
20 require 'hs_config'
21 require 'hs_encoder'
3696bcc Added readme.
Your Name authored
22
23 def log_setup(config)
24 if config['log_type'] == 'FILE'
25 log = Logger.new(config['log_file'])
26 else
27 log = Logger.new(STDOUT)
28 end
29
30 case config['log_level']
31 when 'DEBUG'
32 log.level = Logger::DEBUG
33 when 'INFO'
34 log.level = Logger::INFO
35 when 'WARN'
36 log.level = Logger::WARN
37 when 'ERROR'
38 log.level = Logger::ERROR
39 else
40 log.level = Logger::DEBUG
41 end
42
43 return log
44 end
45
46 # **************************************************************
47 #
48 # Main
49 #
50 # **************************************************************
51
c43a280 Carson McDonald Added ability to terminate segmenter by sending the INT signal.
authored
52 hsencoder = nil
53
54 trap('INT') { hsencoder.stop_encoding if !hsencoder.nil? }
55
3696bcc Added readme.
Your Name authored
56 if ARGV.length != 1
57 puts "Usage: http_streamer.rb <config file>"
58 exit 1
59 end
60
d6af898 Carson McDonald More refactoring.
authored
61 config = HSConfig::load( ARGV[0] )
3696bcc Added readme.
Your Name authored
62
d6af898 Carson McDonald More refactoring.
authored
63 log = log_setup( config )
3696bcc Added readme.
Your Name authored
64
65 log.info('HTTP Streamer started')
66
d6af898 Carson McDonald More refactoring.
authored
67 hstransfer = HSTransfer::init_and_start_transfer_thread( log, config )
3696bcc Added readme.
Your Name authored
68
c43a280 Carson McDonald Added ability to terminate segmenter by sending the INT signal.
authored
69 hsencoder = HSEncoder.new(log, config, hstransfer)
70 hsencoder.start_encoding
3696bcc Added readme.
Your Name authored
71
d6af898 Carson McDonald More refactoring.
authored
72 hstransfer.stop_transfer_thread
3696bcc Added readme.
Your Name authored
73
74 log.info('HTTP Streamer terminated')
Something went wrong with that request. Please try again.