rsence 2.1.11 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/INSTALL.rdoc +5 -3
- data/README.rdoc +23 -22
- data/VERSION +1 -1
- data/conf/default_conf.yaml +65 -29
- data/conf/rsence_command_strings.yaml +101 -71
- data/js/comm/autosync/autosync.js +3 -3
- data/js/comm/jsloader/jsloader.js +16 -3
- data/js/comm/queue/queue.js +1 -1
- data/js/comm/transporter/transporter.js +106 -83
- data/js/comm/values/values.js +8 -2
- data/js/controls/button/button.js +9 -4
- data/js/controls/button/themes/default/button.css +1 -1
- data/js/controls/checkbox/themes/default/checkbox.css +1 -1
- data/js/controls/dialogs/sheet/sheet.js +27 -18
- data/js/controls/radiobutton/themes/default/radiobutton.css +1 -1
- data/js/controls/searchfield/searchfield.coffee +2 -0
- data/js/controls/searchfield/themes/default/searchfield.css +96 -0
- data/js/controls/searchfield/themes/default/searchfield.html +12 -0
- data/js/controls/searchfield/themes/default/searchfield_parts1-ie6.gif +0 -0
- data/js/controls/searchfield/themes/default/searchfield_parts1.png +0 -0
- data/js/controls/sliders/slider/slider.js +7 -1
- data/js/controls/stepper/stepper.js +6 -1
- data/js/controls/stringview/stringview.js +50 -39
- data/js/controls/tab/tab.js +103 -7
- data/js/controls/tab/themes/default/tab.css +2 -0
- data/js/controls/textarea/themes/default/textarea.css +4 -0
- data/js/controls/textcontrol/textcontrol.js +32 -2
- data/js/controls/textcontrol/themes/default/textcontrol.css +17 -2
- data/js/controls/uploader/themes/default/uploader.css +3 -3
- data/js/controls/uploader/themes/default/uploader.html +1 -1
- data/js/controls/uploader/uploader.coffee +110 -0
- data/js/controls/window/themes/default/window.css +28 -5
- data/js/controls/window/themes/default/window.html +2 -0
- data/js/controls/window/window.js +5 -1
- data/js/core/class/class.js +22 -4
- data/js/core/elem/elem.coffee +816 -0
- data/js/core/event/event.js +2 -2
- data/js/core/rsence_ns/rsence_ns.coffee +31 -0
- data/js/core/rsence_ns/rsence_ns.js +6 -6
- data/js/datetime/calendar/calendar.coffee +307 -0
- data/js/datetime/calendar/themes/default/calendar.css +90 -9
- data/js/datetime/calendar/themes/default/calendar.html +11 -0
- data/js/datetime/calendar/themes/default/calendar_bg-ie6.gif +0 -0
- data/js/datetime/calendar/themes/default/calendar_bg.png +0 -0
- data/js/datetime/calendar/themes/default/calendar_parts1-ie6.gif +0 -0
- data/js/datetime/calendar/themes/default/calendar_parts1.png +0 -0
- data/js/datetime/calendar/themes/default/calendar_parts2-ie6.gif +0 -0
- data/js/datetime/calendar/themes/default/calendar_parts2.png +0 -0
- data/js/datetime/datetimepicker/datetimepicker.js +217 -0
- data/js/datetime/datetimevalue/datetimevalue.js +22 -5
- data/js/datetime/timesheet/themes/default/timesheet.css +51 -22
- data/js/datetime/timesheet/themes/default/timesheet.html +4 -2
- data/js/datetime/timesheet/timesheet.js +782 -192
- data/js/datetime/timesheet_item/themes/default/timesheet_item.css +42 -11
- data/js/datetime/timesheet_item/themes/default/timesheet_item.html +4 -2
- data/js/datetime/timesheet_item/themes/default/timesheet_item_icons.png +0 -0
- data/js/datetime/timesheet_item/timesheet_item.js +158 -254
- data/js/datetime/timesheet_item_edit/timesheet_item_edit.js +0 -274
- data/js/foundation/application/application.js +52 -9
- data/js/foundation/control/eventresponder/eventresponder.js +7 -4
- data/js/foundation/control/valueaction/valueaction.js +71 -0
- data/js/foundation/eventmanager/eventmanager.js +71 -33
- data/js/foundation/geom/rect/rect.js +39 -7
- data/js/foundation/json_renderer/json_renderer.js +278 -62
- data/js/foundation/locale_settings/locale_settings.js +131 -0
- data/js/foundation/system/system.js +40 -13
- data/js/foundation/thememanager/thememanager.js +21 -0
- data/js/foundation/view/markupview/markupview.js +12 -12
- data/js/foundation/view/view.js +221 -27
- data/js/graphics/svgcontrol/svgcontrol.js +400 -0
- data/js/lists/checkboxlist/checkboxlist.js +18 -7
- data/js/lists/listitems/listitems.js +52 -38
- data/js/lists/radiobuttonlist/radiobuttonlist.js +23 -7
- data/js/menus/menuitem/menuitem.js +5 -0
- data/js/menus/menuitem/themes/default/menuitem.css +45 -0
- data/js/menus/menuitem/themes/default/menuitem.html +4 -0
- data/js/menus/minimenu/minimenu.js +47 -16
- data/js/menus/minimenuitem/minimenuitem.js +62 -0
- data/js/menus/{minimenu/minimenuitem → minimenuitem}/themes/default/minimenuitem.css +2 -2
- data/js/menus/{minimenu/minimenuitem → minimenuitem}/themes/default/minimenuitem.html +0 -0
- data/js/menus/{minimenu/minimenuitem → minimenuitem}/themes/default/minimenuitem_checkmark.png +0 -0
- data/js/menus/popupmenu/popupmenu.js +14 -0
- data/js/menus/popupmenu/themes/default/popupmenu.css +65 -0
- data/js/menus/popupmenu/themes/default/popupmenu.html +7 -0
- data/js/menus/popupmenu/themes/default/popupmenu.png +0 -0
- data/js/no_pkg/no_pkg.js +2 -0
- data/js/util/reloadapp/reloadapp.js +1 -1
- data/js/views/scrollview/scrollview.js +6 -0
- data/lib/rsence.rb +136 -3
- data/lib/rsence/argv.rb +218 -0
- data/lib/rsence/argv/argv_util.rb +58 -0
- data/lib/rsence/argv/env_check.rb +58 -0
- data/lib/rsence/argv/help_argv.rb +15 -0
- data/lib/rsence/argv/initenv_argv.rb +218 -0
- data/lib/rsence/argv/save_argv.rb +92 -0
- data/lib/rsence/argv/startup_argv.rb +118 -0
- data/lib/rsence/argv/status_argv.rb +132 -0
- data/lib/rsence/argv/test_port.rb +32 -0
- data/lib/{daemon → rsence}/daemon.rb +67 -23
- data/lib/{conf/default.rb → rsence/default_config.rb} +18 -10
- data/lib/{plugins → rsence}/dependencies.rb +0 -0
- data/lib/{util → rsence}/gzstring.rb +0 -0
- data/lib/rsence/http.rb +3 -0
- data/lib/{http → rsence/http}/broker.rb +106 -19
- data/lib/{http → rsence/http}/rackup.rb +0 -0
- data/lib/{http → rsence/http}/request.rb +0 -4
- data/lib/{http → rsence/http}/response.rb +0 -1
- data/lib/{session → rsence}/msg.rb +17 -1
- data/lib/{plugins → rsence}/pluginmanager.rb +29 -12
- data/lib/{plugins → rsence}/plugins.rb +7 -7
- data/lib/{plugins → rsence/plugins}/gui_plugin.rb +8 -3
- data/lib/{plugins → rsence/plugins}/guiparser.rb +9 -6
- data/lib/{plugins → rsence/plugins}/plugin.rb +23 -4
- data/lib/{plugins → rsence/plugins}/plugin_base.rb +11 -1
- data/lib/{plugins → rsence/plugins}/plugin_plugins.rb +2 -2
- data/lib/{plugins → rsence/plugins}/plugin_sqlite_db.rb +0 -0
- data/lib/{plugins → rsence/plugins}/servlet.rb +0 -0
- data/lib/{session → rsence}/sessionmanager.rb +101 -39
- data/lib/{session → rsence}/sessionstorage.rb +30 -16
- data/lib/{daemon → rsence}/sigcomm.rb +0 -0
- data/lib/{transporter → rsence}/transporter.rb +13 -11
- data/lib/{values/hvalue.rb → rsence/value.rb} +6 -1
- data/lib/{values → rsence}/valuemanager.rb +1 -1
- data/plugins/client_pkg/client_pkg.rb +14 -4
- data/plugins/client_pkg/info.yaml +2 -2
- data/plugins/client_pkg/lib/client_pkg_build.rb +145 -45
- data/plugins/client_pkg/lib/client_pkg_cache.rb +1 -1
- data/plugins/client_pkg/lib/client_pkg_serve.rb +1 -1
- data/plugins/main/main.rb +43 -3
- data/plugins/main/tmpl/index.html +2 -10
- data/plugins/main/values.yaml +3 -1
- data/plugins/ticket/lib/common.rb +6 -3
- data/plugins/ticket/ticket.rb +11 -3
- metadata +144 -174
- data/js/comm/autosync/js.inc +0 -0
- data/js/comm/js.inc +0 -0
- data/js/comm/jsloader/js.inc +0 -0
- data/js/comm/queue/js.inc +0 -0
- data/js/comm/session/js.inc +0 -0
- data/js/comm/sessionwatcher/js.inc +0 -0
- data/js/comm/transporter/js.inc +0 -0
- data/js/comm/urlresponder/js.inc +0 -0
- data/js/comm/values/js.inc +0 -0
- data/js/controls/button/js.inc +0 -0
- data/js/controls/checkbox/js.inc +0 -0
- data/js/controls/dialogs/alert_sheet/js.inc +0 -0
- data/js/controls/dialogs/confirm_sheet/js.inc +0 -0
- data/js/controls/dialogs/sheet/js.inc +0 -0
- data/js/controls/imageview/js.inc +0 -0
- data/js/controls/passwordcontrol/js.inc +0 -0
- data/js/controls/progress/progressbar/js.inc +0 -0
- data/js/controls/progress/progressindicator/js.inc +0 -0
- data/js/controls/radiobutton/js.inc +0 -0
- data/js/controls/sliders/slider/js.inc +0 -0
- data/js/controls/sliders/vslider/js.inc +0 -0
- data/js/controls/stepper/js.inc +0 -0
- data/js/controls/stringview/js.inc +0 -0
- data/js/controls/tab/js.inc +0 -0
- data/js/controls/textarea/js.inc +0 -0
- data/js/controls/textcontrol/js.inc +0 -0
- data/js/controls/uploader/js.inc +0 -0
- data/js/controls/uploader/uploader.js +0 -154
- data/js/controls/validatorview/js.inc +0 -0
- data/js/controls/window/js.inc +0 -0
- data/js/core/class/js.inc +0 -0
- data/js/core/elem/elem.js +0 -1325
- data/js/core/elem/js.inc +0 -0
- data/js/core/event/js.inc +0 -0
- data/js/core/iefix/js.inc +0 -0
- data/js/core/rsence_ns/js.inc +0 -0
- data/js/datetime/calendar/calendar.js +0 -198
- data/js/datetime/calendar/js.inc +0 -0
- data/js/datetime/datetimevalue/js.inc +0 -0
- data/js/datetime/timesheet/js.inc +0 -0
- data/js/datetime/timesheet/old_timesheet.js +0 -292
- data/js/datetime/timesheet/themes/default/old_timesheet.css +0 -30
- data/js/datetime/timesheet/themes/default/old_timesheet.html +0 -2
- data/js/datetime/timesheet_item/js.inc +0 -0
- data/js/datetime/timesheet_item/old_timesheet_item.js +0 -308
- data/js/datetime/timesheet_item/themes/default/old_timesheet_item.css +0 -42
- data/js/datetime/timesheet_item/themes/default/old_timesheet_item.html +0 -8
- data/js/datetime/timesheet_item_edit/js.inc +0 -0
- data/js/datetime/timesheet_item_edit/old_timesheet_item_edit.js +0 -274
- data/js/foundation/application/js.inc +0 -0
- data/js/foundation/control/controldefaults/js.inc +0 -0
- data/js/foundation/control/dummyvalue/js.inc +0 -0
- data/js/foundation/control/dyncontrol/js.inc +0 -0
- data/js/foundation/control/eventresponder/js.inc +0 -0
- data/js/foundation/control/js.inc +0 -0
- data/js/foundation/control/valuematrix/js.inc +0 -0
- data/js/foundation/control/valueresponder/js.inc +0 -0
- data/js/foundation/eventmanager/js.inc +0 -0
- data/js/foundation/geom/point/js.inc +0 -0
- data/js/foundation/geom/rect/js.inc +0 -0
- data/js/foundation/json_renderer/js.inc +0 -0
- data/js/foundation/system/js.inc +0 -0
- data/js/foundation/thememanager/js.inc +0 -0
- data/js/foundation/value/js.inc +0 -0
- data/js/foundation/view/js.inc +0 -0
- data/js/foundation/view/markupview/js.inc +0 -0
- data/js/foundation/view/morphanimation/js.inc +0 -0
- data/js/foundation/view/viewdefaults/js.inc +0 -0
- data/js/lists/checkboxlist/js.inc +0 -0
- data/js/lists/listitems/js.inc +0 -0
- data/js/lists/propertylist/js.inc +0 -0
- data/js/lists/propertylist/propertylisteditor/js.inc +0 -0
- data/js/lists/radiobuttonlist/js.inc +0 -0
- data/js/menus/minimenu/js.inc +0 -0
- data/js/menus/minimenu/minimenuitem/js.inc +0 -0
- data/js/menus/minimenu/minimenuitem/minimenuitem.js +0 -33
- data/js/util/reloadapp/js.inc +0 -0
- data/js/util/sha/js.inc +0 -0
- data/js/views/centerview/js.inc +0 -0
- data/js/views/inlineview/js.inc +0 -0
- data/js/views/scrollview/js.inc +0 -0
- data/lib/conf/argv.rb +0 -880
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
module RSence
|
|
2
|
+
module ArgvUtil
|
|
3
|
+
# Main argument parser for the status command, sends the INFO (or PWR on linux) POSIX signal to
|
|
4
|
+
# the process, if running.
|
|
5
|
+
# Checks if the process responds on the port and address it's configured for.
|
|
6
|
+
def parse_status_argv
|
|
7
|
+
init_args
|
|
8
|
+
expect_option = false
|
|
9
|
+
option_name = false
|
|
10
|
+
if @argv.length >= 2
|
|
11
|
+
@argv[1..-1].each_with_index do |arg,i|
|
|
12
|
+
if expect_option
|
|
13
|
+
if [:port].include?(option_name) and arg.to_i.to_s != arg
|
|
14
|
+
puts ERB.new( @strs[:messages][:invalid_option_expected_number] ).result( binding )
|
|
15
|
+
exit
|
|
16
|
+
elsif option_name == :conf_files
|
|
17
|
+
if not File.exists?( arg ) or not File.file?( arg )
|
|
18
|
+
puts ERB.new( @strs[:messages][:no_such_configuration_file] ).result( binding )
|
|
19
|
+
exit
|
|
20
|
+
else
|
|
21
|
+
@args[:conf_files].push( arg )
|
|
22
|
+
end
|
|
23
|
+
else
|
|
24
|
+
@args[option_name] = arg
|
|
25
|
+
end
|
|
26
|
+
expect_option = false
|
|
27
|
+
else
|
|
28
|
+
if arg.start_with?('--')
|
|
29
|
+
if arg == '--debug'
|
|
30
|
+
set_debug
|
|
31
|
+
elsif arg == '--verbose'
|
|
32
|
+
set_verbose
|
|
33
|
+
elsif arg == '--port'
|
|
34
|
+
expect_option = true
|
|
35
|
+
option_name = :port
|
|
36
|
+
elsif arg == '--addr'
|
|
37
|
+
expect_option = true
|
|
38
|
+
option_name = :addr
|
|
39
|
+
elsif arg == '--conf' or arg == '--config'
|
|
40
|
+
expect_option = true
|
|
41
|
+
option_name = :conf_files
|
|
42
|
+
else
|
|
43
|
+
invalid_option(arg)
|
|
44
|
+
end
|
|
45
|
+
elsif arg.start_with?('-')
|
|
46
|
+
arg.split('')[1..-1].each do |chr|
|
|
47
|
+
if chr == 'd'
|
|
48
|
+
set_debug
|
|
49
|
+
elsif chr == 'v'
|
|
50
|
+
set_verbose
|
|
51
|
+
else
|
|
52
|
+
invalid_option(arg,chr)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
elsif valid_env?(arg)
|
|
56
|
+
@args[:env_path] = File.expand_path(arg)
|
|
57
|
+
@args[:conf_files].unshift( File.expand_path( File.join( arg, 'conf', 'config.yaml' ) ) )
|
|
58
|
+
else
|
|
59
|
+
invalid_env( arg )
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
if expect_option
|
|
64
|
+
puts ERB.new( @strs[:messages][:no_value_for_option] ).result( binding )
|
|
65
|
+
exit
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
if valid_env?(@args[:env_path])
|
|
69
|
+
conf_file = File.expand_path( File.join( @args[:env_path], 'conf', 'config.yaml' ) )
|
|
70
|
+
@args[:conf_files].unshift( conf_file ) unless @args[:conf_files].include?( conf_file )
|
|
71
|
+
else
|
|
72
|
+
invalid_env
|
|
73
|
+
end
|
|
74
|
+
require 'rsence/default_config'
|
|
75
|
+
require 'socket'
|
|
76
|
+
config = Configuration.new(@args).config
|
|
77
|
+
port = config[:http_server][:port]
|
|
78
|
+
addr = config[:http_server][:bind_address]
|
|
79
|
+
port_status = []
|
|
80
|
+
if addr == '0.0.0.0' and Socket.respond_to?(:ip_address_list)
|
|
81
|
+
Socket.ip_address_list.each do |if_addr|
|
|
82
|
+
if test_port( port, if_addr.ip_address )
|
|
83
|
+
port_status.push( if_addr.ip_address )
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
else
|
|
87
|
+
port_status.push( addr )
|
|
88
|
+
end
|
|
89
|
+
addr_descr = port_status.join(":#{port}, ")+":#{port}"
|
|
90
|
+
if RSence.pid_support?
|
|
91
|
+
pid_fn = config[:daemon][:pid_fn]
|
|
92
|
+
if File.exists?( pid_fn )
|
|
93
|
+
pid = File.read( pid_fn ).to_i
|
|
94
|
+
sig_name = RSence.info_signal_name
|
|
95
|
+
pid_status = RSence::SIGComm.wait_signal_response(
|
|
96
|
+
pid, pid_fn, sig_name, 3
|
|
97
|
+
)
|
|
98
|
+
else
|
|
99
|
+
warn @strs[:messages][:no_pid_file] if @args[:verbose]
|
|
100
|
+
pid_status = nil
|
|
101
|
+
end
|
|
102
|
+
else
|
|
103
|
+
warn @strs[:messages][:no_pid_support] if @args[:verbose]
|
|
104
|
+
pid_status = nil
|
|
105
|
+
end
|
|
106
|
+
addr_descr = port_status.join(":#{port} and ")+":#{port}" unless port_status.empty?
|
|
107
|
+
if not RSence.pid_support? or pid_status == nil
|
|
108
|
+
if RSence.pid_support?
|
|
109
|
+
puts @strs[:messages][:no_pid]
|
|
110
|
+
else
|
|
111
|
+
puts @strs[:messages][:no_pid_support]
|
|
112
|
+
end
|
|
113
|
+
unless port_status.empty?
|
|
114
|
+
puts ERB.new( @strs[:messages][:something_responds] ).result( binding )
|
|
115
|
+
end
|
|
116
|
+
elsif pid_status == false
|
|
117
|
+
if port_status.empty?
|
|
118
|
+
puts ERB.new( @strs[:messages][:no_process_running_and_nothing_responds] ).result( binding )
|
|
119
|
+
else
|
|
120
|
+
puts ERB.new( @strs[:messages][:no_process_running_but_something_responds] ).result( binding )
|
|
121
|
+
end
|
|
122
|
+
else
|
|
123
|
+
if port_status.empty?
|
|
124
|
+
puts ERB.new( @strs[:messages][:process_running_but_nothing_responds] ).result( binding )
|
|
125
|
+
else
|
|
126
|
+
addr_descr = port_status.join(":#{port} and ")+":#{port}"
|
|
127
|
+
puts ERB.new( @strs[:messages][:process_running_and_responds] ).result( binding )
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
|
|
2
|
+
module RSence
|
|
3
|
+
module ArgvUtil
|
|
4
|
+
|
|
5
|
+
# Tests, if the port on addr responds or refuses the connection.
|
|
6
|
+
# Automatically replaces '0.0.0.0' with '127.0.0.1'
|
|
7
|
+
def test_port( port, addr='127.0.0.1' )
|
|
8
|
+
require 'socket'
|
|
9
|
+
begin
|
|
10
|
+
addr = '127.0.0.1' if addr == '0.0.0.0'
|
|
11
|
+
if RUBY_VERSION.to_f >= 1.9
|
|
12
|
+
sock = TCPSocket.open( addr, port )
|
|
13
|
+
else
|
|
14
|
+
begin
|
|
15
|
+
sock = TCPsocket.open( addr, port )
|
|
16
|
+
rescue NameError => e
|
|
17
|
+
warn "TCPsocket not available, trying TCPSocket.."
|
|
18
|
+
sock = TCPSocket.open( addr, port )
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
sock.close
|
|
22
|
+
return true
|
|
23
|
+
rescue Errno::ECONNREFUSED
|
|
24
|
+
return false
|
|
25
|
+
rescue => e
|
|
26
|
+
warn e.inspect
|
|
27
|
+
return false
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
require 'rubygems'
|
|
12
12
|
|
|
13
13
|
# Transporter is the top-level handler for calls coming from the javascript COMM.Transporter.
|
|
14
|
-
require '
|
|
14
|
+
require 'rsence/transporter'
|
|
15
15
|
|
|
16
16
|
# Broker routes requests to the correct handler
|
|
17
|
-
require 'http
|
|
17
|
+
require 'rsence/http'
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
module RSence
|
|
@@ -276,9 +276,44 @@ module RSence
|
|
|
276
276
|
"RSence-#{RSence.version} on #{url} in #{env_path}"
|
|
277
277
|
end
|
|
278
278
|
|
|
279
|
+
def start_broker( conf )
|
|
280
|
+
http_delayed_seconds = RSence.config[:daemon][:http_delayed_start].to_i
|
|
281
|
+
if http_delayed_seconds == -1
|
|
282
|
+
puts "The HTTP Broker is disabled. RSence won't bind a http listener to any address."
|
|
283
|
+
else
|
|
284
|
+
if http_delayed_seconds > 0
|
|
285
|
+
puts "Delaying the start of the HTTP Broker by #{http_delayed_seconds} seconds."
|
|
286
|
+
if http_delayed_seconds > 10
|
|
287
|
+
# report when starting in 10 second intervals
|
|
288
|
+
sleep_remainder = http_delayed_seconds % 10
|
|
289
|
+
sleep_count = http_delayed_seconds / 10
|
|
290
|
+
sleep_time_left = http_delayed_seconds
|
|
291
|
+
sleep_count.times do |sleep_count_num|
|
|
292
|
+
puts "Waiting #{sleep_time_left} seconds..."
|
|
293
|
+
sleep 10
|
|
294
|
+
sleep_time_left -= 10
|
|
295
|
+
end
|
|
296
|
+
if sleep_remainder != 0
|
|
297
|
+
puts "Waiting #{sleep_remainder} seconds..."
|
|
298
|
+
sleep sleep_remainder
|
|
299
|
+
end
|
|
300
|
+
else
|
|
301
|
+
sleep http_delayed_seconds
|
|
302
|
+
end
|
|
303
|
+
puts "Starting the HTTP Broker now."
|
|
304
|
+
end
|
|
305
|
+
# This is the main http handler instance:
|
|
306
|
+
@broker = Broker.start(
|
|
307
|
+
@transporter,
|
|
308
|
+
conf
|
|
309
|
+
)
|
|
310
|
+
end
|
|
311
|
+
end
|
|
312
|
+
|
|
279
313
|
# RSence top-level run handler. Almost identical to start.
|
|
280
314
|
def run
|
|
281
315
|
|
|
316
|
+
# Sets the process name
|
|
282
317
|
$0 = ps_name
|
|
283
318
|
|
|
284
319
|
puts "Starting as a foreground process." if RSence.args[:verbose]
|
|
@@ -291,13 +326,10 @@ module RSence
|
|
|
291
326
|
unless RSence.args[:log_fg]
|
|
292
327
|
Daemon.start_logging( self )
|
|
293
328
|
end
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
conf
|
|
299
|
-
)
|
|
300
|
-
|
|
329
|
+
|
|
330
|
+
autosave_loop if RSence.config[:daemon][:autosave_interval] > 0
|
|
331
|
+
start_broker( conf )
|
|
332
|
+
|
|
301
333
|
end
|
|
302
334
|
|
|
303
335
|
# Returns the pid file path.
|
|
@@ -319,28 +351,40 @@ module RSence
|
|
|
319
351
|
def port
|
|
320
352
|
RSence.config[:http_server][:port]
|
|
321
353
|
end
|
|
354
|
+
|
|
355
|
+
# Saves plugin and session state periodically
|
|
356
|
+
def autosave_loop
|
|
357
|
+
Thread.new do
|
|
358
|
+
Thread.pass
|
|
359
|
+
sleep RSence.config[:daemon][:autosave_interval]
|
|
360
|
+
while true
|
|
361
|
+
if @transporter.online?
|
|
362
|
+
save
|
|
363
|
+
end
|
|
364
|
+
sleep RSence.config[:daemon][:autosave_interval]
|
|
365
|
+
end
|
|
366
|
+
end
|
|
367
|
+
end
|
|
322
368
|
|
|
323
369
|
# Called by Controller#start, contains RSence-specific operations
|
|
324
370
|
def start
|
|
325
371
|
|
|
372
|
+
# Sets the process name
|
|
326
373
|
$0 = ps_name
|
|
327
374
|
|
|
328
375
|
@transporter = Transporter.new
|
|
329
|
-
|
|
376
|
+
|
|
330
377
|
conf = RSence.config[:http_server]
|
|
331
|
-
|
|
378
|
+
|
|
332
379
|
unless RSence.args[:log_fg]
|
|
333
380
|
Daemon.start_logging( self )
|
|
334
381
|
STDIN.reopen( "/dev/null" )
|
|
335
382
|
end
|
|
336
|
-
|
|
383
|
+
|
|
337
384
|
Process.setsid
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
@transporter,
|
|
342
|
-
conf
|
|
343
|
-
)
|
|
385
|
+
|
|
386
|
+
autosave_loop if RSence.config[:daemon][:autosave_interval] > 0
|
|
387
|
+
start_broker( conf )
|
|
344
388
|
yield @broker
|
|
345
389
|
|
|
346
390
|
end
|
|
@@ -357,7 +401,7 @@ module RSence
|
|
|
357
401
|
|
|
358
402
|
# Called on INFO (PWR) signals ("Alive?")
|
|
359
403
|
def info
|
|
360
|
-
puts "#{Time.now.strftime('%Y-%m-%d %H:%M:%S')} -- RSence version #{RSence.version} is running."
|
|
404
|
+
puts "#{Time.now.strftime('%Y-%m-%d %H:%M:%S')} -- RSence version #{RSence.version} is running the project: #{RSence.args[:env_path]}"
|
|
361
405
|
end
|
|
362
406
|
|
|
363
407
|
# Called on ALRM signals (save data, reload all plugins manually)
|
|
@@ -381,11 +425,11 @@ module RSence
|
|
|
381
425
|
# Save state
|
|
382
426
|
def save
|
|
383
427
|
puts "#{Time.now.strftime('%Y-%m-%d %H:%M:%S')} -- Saving state..."
|
|
384
|
-
transporter_state = @transporter.online?
|
|
385
|
-
@transporter.online = false
|
|
386
|
-
@transporter.plugins.delegate(:flush)
|
|
428
|
+
# transporter_state = @transporter.online?
|
|
429
|
+
# @transporter.online = false
|
|
387
430
|
@transporter.sessions.store_sessions
|
|
388
|
-
@transporter.
|
|
431
|
+
@transporter.plugins.delegate(:flush)
|
|
432
|
+
# @transporter.online = transporter_state
|
|
389
433
|
puts "#{Time.now.strftime('%Y-%m-%d %H:%M:%S')} -- State saved."
|
|
390
434
|
end
|
|
391
435
|
|
|
@@ -12,7 +12,6 @@ require 'rack'
|
|
|
12
12
|
require 'yaml'
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
|
|
16
15
|
module RSence
|
|
17
16
|
|
|
18
17
|
|
|
@@ -45,7 +44,7 @@ module RSence
|
|
|
45
44
|
# @param [Hash] source Has its items merged to `target` unless a key with an identical value already exists in `target`. If an item class is Array, then uses {#array_merge} to combine them.
|
|
46
45
|
def hash_merge( target, source )
|
|
47
46
|
source.each do |key,item|
|
|
48
|
-
if not target.has_key?key or target[key] != item
|
|
47
|
+
if not target.has_key?( key ) or target[key] != item
|
|
49
48
|
if item.class == Array
|
|
50
49
|
target[key] = [] unless target.has_key?(key)
|
|
51
50
|
array_merge( target[key], item )
|
|
@@ -143,14 +142,23 @@ module RSence
|
|
|
143
142
|
config[:http_server][:bind_address] = args[:addr] if args[:addr]
|
|
144
143
|
config[:http_server][:rack_require] = args[:server] if args[:server]
|
|
145
144
|
config[:session_conf][:reset_sessions] = true if args[:reset_ses]
|
|
145
|
+
config[:daemon][:http_delayed_start] = args[:http_delayed_start] if args[:http_delayed_start] != nil
|
|
146
146
|
|
|
147
147
|
config[:client_pkg][:no_obfuscation] = true if args[:client_pkg_no_obfuscation]
|
|
148
148
|
config[:client_pkg][:no_whitespace_removal] = true if args[:client_pkg_no_whitespace_removal]
|
|
149
149
|
|
|
150
150
|
# Sets the default pid and log paths used by the HTTPDaemon
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
151
|
+
if config[:daemon].has_key?(:pid_fn)
|
|
152
|
+
config[:daemon][:pid_fn] = File.join(pidpath, config[:daemon][:pid_fn] )
|
|
153
|
+
else
|
|
154
|
+
config[:daemon][:pid_fn] = File.join(pidpath, "rsence.pid")
|
|
155
|
+
end
|
|
156
|
+
if config[:daemon].has_key?(:log_fn)
|
|
157
|
+
config[:daemon][:log_fn] = File.join(logpath, config[:daemon][:log_fn] )
|
|
158
|
+
else
|
|
159
|
+
config[:daemon][:log_fn] = File.join(logpath, "rsence")
|
|
160
|
+
end
|
|
161
|
+
|
|
154
162
|
# Check database path for sqlite databases.
|
|
155
163
|
if config[:database][:ses_db].start_with?('sqlite://') and not dont_expand_path
|
|
156
164
|
db_url = File.expand_path( config[:database][:ses_db].split('sqlite://')[1], args[:env_path] )
|
|
@@ -189,11 +197,11 @@ module RSence
|
|
|
189
197
|
end
|
|
190
198
|
end
|
|
191
199
|
|
|
192
|
-
if RUBY_VERSION.to_f >= 1.9
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
end
|
|
200
|
+
# if RUBY_VERSION.to_f >= 1.9
|
|
201
|
+
# # The encodings mess up compression when using ruby1.9
|
|
202
|
+
# warn "Disabling gzip support for ruby 1.9" if args[:debug]
|
|
203
|
+
# config[:no_gzip] = true
|
|
204
|
+
# end
|
|
197
205
|
|
|
198
206
|
# The default address of the index_html plugin
|
|
199
207
|
unless config[:index_html].has_key?(:respond_address)
|
|
File without changes
|
|
File without changes
|
data/lib/rsence/http.rb
ADDED
|
@@ -10,11 +10,10 @@ require 'rubygems'
|
|
|
10
10
|
require 'rack'
|
|
11
11
|
|
|
12
12
|
## Minimally WEBrick -compatible response object
|
|
13
|
-
require 'http/response'
|
|
13
|
+
require 'rsence/http/response'
|
|
14
14
|
|
|
15
15
|
## Minimally WEBrick -compatible request object
|
|
16
|
-
require 'http/request'
|
|
17
|
-
|
|
16
|
+
require 'rsence/http/request'
|
|
18
17
|
|
|
19
18
|
module RSence
|
|
20
19
|
|
|
@@ -41,8 +40,15 @@ class Broker
|
|
|
41
40
|
response = Response.new
|
|
42
41
|
request_method = request.request_method.downcase
|
|
43
42
|
dispatcher = dispatcher_class.new( request, response )
|
|
44
|
-
dispatcher.
|
|
45
|
-
|
|
43
|
+
if dispatcher.respond_to?( request_method )
|
|
44
|
+
begin
|
|
45
|
+
dispatcher.send( request_method )
|
|
46
|
+
rescue => e
|
|
47
|
+
dispatcher.server_error( e )
|
|
48
|
+
end
|
|
49
|
+
else
|
|
50
|
+
dispatcher.not_implemented( request.request_method )
|
|
51
|
+
end
|
|
46
52
|
response_body = response.body
|
|
47
53
|
response.header['Content-Length'] = response.body_bytes unless response.header.has_key?('Content-Length')
|
|
48
54
|
return [response.status, response.header, response_body]
|
|
@@ -55,7 +61,6 @@ class Broker
|
|
|
55
61
|
# @return [Broker] An instance of Broker with a {Request} instance as +@request+ and a {Response} instance as +@response+
|
|
56
62
|
def dispatcher_class
|
|
57
63
|
@dispatcher ||= Class.new(self.class) do
|
|
58
|
-
attr_accessor :content_type
|
|
59
64
|
def initialize(request,response)
|
|
60
65
|
@request = request
|
|
61
66
|
@response = response
|
|
@@ -90,7 +95,16 @@ class Broker
|
|
|
90
95
|
sleep 0.2
|
|
91
96
|
end
|
|
92
97
|
puts "..#{host}:#{port} responds!" if ::RSence.args[:debug]
|
|
93
|
-
|
|
98
|
+
if host == '0.0.0.0' and Socket.respond_to?(:ip_address_list)
|
|
99
|
+
puts "RSence is online and responds on the addresses:"
|
|
100
|
+
Socket.ip_address_list.each do |if_addr|
|
|
101
|
+
if RSence.argv.test_port( port, if_addr.ip_address )
|
|
102
|
+
puts " http://#{if_addr.ip_address}:#{port}#{::RSence.config[:base_url]}"
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
else
|
|
106
|
+
puts "RSence is online on the address http://#{host}:#{port}#{::RSence.config[:base_url]}"
|
|
107
|
+
end
|
|
94
108
|
@@transporter.online = true
|
|
95
109
|
end
|
|
96
110
|
|
|
@@ -99,11 +113,12 @@ class Broker
|
|
|
99
113
|
# Loads the selected web-server (default is 'mongrel')
|
|
100
114
|
rack_require = conf[:rack_require]
|
|
101
115
|
puts conf.inspect if RSence.args[:debug]
|
|
102
|
-
|
|
116
|
+
|
|
103
117
|
require rack_require
|
|
104
118
|
|
|
105
119
|
# Selects the handler for Rack
|
|
106
120
|
handler = {
|
|
121
|
+
'mongrel2' => lambda { Rack::Handler::Mongrel2 },
|
|
107
122
|
'webrick' => lambda { Rack::Handler::WEBrick },
|
|
108
123
|
'ebb' => lambda { Rack::Handler::Ebb },
|
|
109
124
|
'thin' => lambda { Rack::Handler::Thin },
|
|
@@ -111,41 +126,113 @@ class Broker
|
|
|
111
126
|
'unicorn' => lambda { Rack::Handler::Unicorn },
|
|
112
127
|
'rainbows' => lambda { Rack::Handler::Rainbows }
|
|
113
128
|
}[rack_require].call
|
|
114
|
-
|
|
115
129
|
handler.run( Rack::Lint.new(self.new), :Host => host, :Port => port )
|
|
116
|
-
|
|
117
130
|
end
|
|
118
131
|
|
|
119
132
|
# Generic 404 error handler. Just sets up response status, headers, body as a small "Page Not Found" html page
|
|
120
133
|
def not_found
|
|
121
134
|
puts "/404: #{@request.fullpath.inspect}" if RSence.args[:verbose]
|
|
122
135
|
@response.status = 404
|
|
123
|
-
err404 =
|
|
136
|
+
err404 = "<html><head><title>404 - Page Not Found</title></head><body>404 - Page "#{@request.fullpath}" Not Found</body></html>"
|
|
124
137
|
@response['Content-Type'] = 'text/html; charset=UTF-8'
|
|
125
|
-
@response['Content-Length'] = err404.bytesize.to_s
|
|
126
138
|
@response.body = err404
|
|
127
139
|
end
|
|
128
140
|
|
|
129
141
|
# Routes POST requests to {Transporter#servlet}
|
|
130
142
|
def post
|
|
131
|
-
|
|
132
143
|
puts "post: #{@request.fullpath}" if RSence.args[:verbose]
|
|
133
|
-
|
|
134
144
|
not_found unless @@transporter.servlet( :post, @request, @response )
|
|
135
|
-
|
|
136
145
|
end
|
|
137
146
|
|
|
138
147
|
# Routes GET requests to {Transporter#servlet}
|
|
139
148
|
def get
|
|
140
|
-
|
|
141
149
|
puts "get: #{@request.fullpath}" if RSence.args[:verbose]
|
|
142
|
-
|
|
143
150
|
not_found unless @@transporter.servlet( :get, @request, @response )
|
|
144
|
-
|
|
145
151
|
end
|
|
146
152
|
|
|
147
|
-
|
|
153
|
+
# Routes HEAD requests to {Transporter#servlet}
|
|
154
|
+
# Uses GET and removes the response body, if nothing matches HEAD directly.
|
|
155
|
+
def head
|
|
156
|
+
puts "head: #{@request.fullpath}" if RSence.args[:verbose]
|
|
157
|
+
return if @@transporter.servlet( :head, @request, @response )
|
|
158
|
+
if @@transporter.servlet( :get, @request, @response )
|
|
159
|
+
@response.body = ''
|
|
160
|
+
else
|
|
161
|
+
not_found
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# Generic 405 (method not allowed) handler.
|
|
166
|
+
def not_allowed( method_name )
|
|
167
|
+
@response.status = 405
|
|
168
|
+
body_txt = "Error 405: The method #{method_name} is not allowed on #{@request.fullpath}.\r\n"
|
|
169
|
+
@response['Content-Type'] = 'text/plain; charset=UTF-8'
|
|
170
|
+
@response.body = body_txt
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
# Generic 501 (method not implemented) handler.
|
|
174
|
+
def not_implemented( method_name )
|
|
175
|
+
@response.status = 501
|
|
176
|
+
body_txt = "Error 501: The method #{method_name} is not implemented on #{@request.fullpath}.\r\n"
|
|
177
|
+
@response['Content-Type'] = 'text/plain; charset=UTF-8'
|
|
178
|
+
@response.body = body_txt
|
|
179
|
+
end
|
|
148
180
|
|
|
181
|
+
# Generic 500 (server error) handler.
|
|
182
|
+
def server_error( e, custom_name='Broker Exception' )
|
|
183
|
+
@response.status = 500
|
|
184
|
+
exception_detail = [
|
|
185
|
+
custom_name,
|
|
186
|
+
"Time: #{Time.now.to_s}",
|
|
187
|
+
"#{'-='*39}-",
|
|
188
|
+
"#{e.class}: #{e.to_s}",
|
|
189
|
+
"\t#{e.backtrace.join("\r\n\t")}",
|
|
190
|
+
"#{'-='*39}-",
|
|
191
|
+
"Request method: #{@request.request_method}",
|
|
192
|
+
"Request path: #{@request.fullpath}",
|
|
193
|
+
"Request headers: #{@request.header.inspect}",
|
|
194
|
+
"#{'-='*39}-\r\n\r\n"
|
|
195
|
+
].join("\r\n")
|
|
196
|
+
$stderr.puts exception_detail
|
|
197
|
+
if RSence.args[:debug]
|
|
198
|
+
body_txt = "Error 500: "+ exception_detail
|
|
199
|
+
else
|
|
200
|
+
body_txt = "Error 500: General server error.\r\n"
|
|
201
|
+
end
|
|
202
|
+
@response['Content-Type'] = 'text/plain; charset=UTF-8'
|
|
203
|
+
@response.body = body_txt
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
# Routes OPTIONS requests to {Transporter#servlet}
|
|
207
|
+
def options
|
|
208
|
+
puts "options: #{@request.fullpath}" if RSence.args[:verbose]
|
|
209
|
+
not_allowed('OPTIONS') unless @@transporter.servlet( :options, @request, @response )
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
# Routes PUT requests to {Transporter#servlet}
|
|
213
|
+
def put
|
|
214
|
+
puts "put: #{@request.fullpath}" if RSence.args[:verbose]
|
|
215
|
+
not_allowed('PUT') unless @@transporter.servlet( :put, @request, @response )
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
# Routes DELETE requests to {Transporter#servlet}
|
|
219
|
+
def delete
|
|
220
|
+
puts "delete: #{@request.fullpath}" if RSence.args[:verbose]
|
|
221
|
+
not_allowed('DELETE') unless @@transporter.servlet( :delete, @request, @response )
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
# Routes TRACE requests to {Transporter#servlet}
|
|
225
|
+
def trace
|
|
226
|
+
puts "trace: #{@request.fullpath}" if RSence.args[:verbose]
|
|
227
|
+
not_allowed('TRACE') unless @@transporter.servlet( :trace, @request, @response )
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
# Routes CONNECT requests to {Transporter#servlet}
|
|
231
|
+
def connect
|
|
232
|
+
puts "connect: #{@request.fullpath}" if RSence.args[:verbose]
|
|
233
|
+
not_allowed('CONNECT') unless @@transporter.servlet( :connect, @request, @response )
|
|
234
|
+
end
|
|
235
|
+
|
|
149
236
|
end
|
|
150
237
|
|
|
151
238
|
end
|