webroar 0.3.1 → 0.4.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/CHANGELOG +48 -1
- data/README +11 -14
- data/Rakefile +1 -1
- data/conf/mime_type.yml +172 -166
- data/conf/server_internal_config.yml +30 -8
- data/doc/user-guide.html +294 -153
- data/doc/user-guide.txt +9 -13
- data/lib/command_runner.rb +1 -0
- data/lib/dependencies.rb +18 -15
- data/lib/installer.rb +115 -50
- data/src/admin_panel/app/controllers/admin_controller.rb +1 -15
- data/src/admin_panel/app/controllers/application_controller.rb +2 -2
- data/src/admin_panel/app/controllers/application_specification_controller.rb +2 -1
- data/src/admin_panel/app/controllers/headers_controller.rb +73 -0
- data/src/admin_panel/app/controllers/mail_specification_controller.rb +10 -0
- data/src/admin_panel/app/controllers/server_specification_controller.rb +14 -0
- data/src/admin_panel/app/helpers/admin_helper.rb +0 -85
- data/src/admin_panel/app/models/app.rb +1 -1
- data/src/admin_panel/app/models/application_specification.rb +33 -25
- data/src/admin_panel/app/models/headers.rb +116 -0
- data/src/admin_panel/app/models/mail_specification.rb +20 -5
- data/src/admin_panel/app/models/server_specification.rb +2 -7
- data/src/admin_panel/app/views/admin/configuration.html.erb +10 -5
- data/src/admin_panel/app/views/exceptions/_exception_list_partial.html.erb +4 -4
- data/src/admin_panel/app/views/graph/_graph_page.html.erb +3 -0
- data/src/admin_panel/app/views/headers/_add_expires_text_box.html.erb +35 -0
- data/src/admin_panel/app/views/headers/_expires_by_type_form.html.erb +65 -0
- data/src/admin_panel/app/views/headers/_headers_table.html.erb +113 -0
- data/src/admin_panel/app/views/mail_specification/_current_spec.html.erb +168 -0
- data/src/admin_panel/app/views/{admin → server_specification}/_add_div.html.erb +1 -1
- data/src/admin_panel/config/initializers/application_constants.rb +6 -0
- data/src/admin_panel/lib/control.rb +6 -3
- data/src/admin_panel/lib/scgi.rb +74 -21
- data/src/admin_panel/lib/yaml_writer.rb +51 -17
- data/src/admin_panel/public/javascripts/application.js +20 -1
- data/src/head/wr_access_log.c +2 -2
- data/src/head/wr_application.c +294 -236
- data/src/head/wr_application.h +8 -8
- data/src/head/wr_configurator.c +451 -517
- data/src/head/wr_configurator.h +10 -115
- data/src/head/wr_connection.c +26 -25
- data/src/head/wr_connection.h +2 -3
- data/src/head/wr_controller.c +110 -93
- data/src/head/wr_controller.h +6 -6
- data/src/head/wr_main.c +31 -24
- data/src/head/wr_request.c +70 -93
- data/src/head/wr_request.h +0 -4
- data/src/head/wr_resolver.c +21 -15
- data/src/head/wr_resolver.h +2 -2
- data/src/head/wr_server.c +36 -26
- data/src/head/wr_server.h +5 -5
- data/src/head/wr_worker.c +551 -512
- data/src/head/wr_worker.h +33 -20
- data/src/helper/wr_config.c +316 -0
- data/src/helper/wr_config.h +235 -0
- data/src/helper/wr_helper.h +1 -5
- data/src/helper/wr_logger.c +4 -4
- data/src/helper/wr_scgi.c +3 -4
- data/src/helper/wr_scgi.h +2 -0
- data/src/helper/wr_string.h +2 -2
- data/src/helper/wr_util.c +3 -1
- data/src/helper/wr_util.h +0 -0
- data/src/helper/wr_yaml_parser.c +30 -0
- data/src/helper/wr_yaml_parser.h +1 -0
- data/src/ruby_lib/exception_tracker/instrumentation/action_controller.rb +2 -1
- data/src/ruby_lib/mailer/smtpmail.rb +7 -4
- data/src/ruby_lib/profiler/instrumentation/action_controller.rb +2 -1
- data/src/ruby_lib/profiler/instrumentation/active_record.rb +3 -0
- data/src/ruby_lib/rack/adapter/rails.rb +14 -7
- data/src/ruby_lib/ruby_interface/client.rb +1 -1
- data/src/ruby_lib/ruby_interface/version.rb +2 -2
- data/src/ruby_lib/webroar_app_loader.rb +4 -2
- data/src/worker/wkr_controller.c +200 -140
- data/src/worker/wkr_http.c +14 -28
- data/src/worker/wkr_http.h +4 -4
- data/src/worker/wkr_http_request.c +12 -11
- data/src/worker/wkr_http_request.h +7 -8
- data/src/worker/wkr_http_response.c +10 -14
- data/src/worker/wkr_http_response.h +0 -1
- data/src/worker/wkr_main.c +74 -140
- data/src/worker/wkr_static.c +295 -108
- data/src/worker/wkr_static.h +20 -7
- data/src/worker/worker.c +245 -70
- data/src/worker/worker.h +46 -34
- data/tasks/compile.rake +128 -175
- data/tasks/test.rake +345 -469
- data/test/spec/webroar_command_spec.rb +23 -0
- metadata +173 -43
- data/src/admin_panel/vendor/plugins/action_mailer_optional_tls/README +0 -34
- data/src/admin_panel/vendor/plugins/action_mailer_optional_tls/Rakefile +0 -13
- data/src/admin_panel/vendor/plugins/action_mailer_optional_tls/init.rb +0 -5
- data/src/admin_panel/vendor/plugins/action_mailer_optional_tls/lib/action_mailer_tls.rb +0 -16
- data/src/admin_panel/vendor/plugins/action_mailer_optional_tls/lib/smtp_tls.rb +0 -123
- data/src/admin_panel/vendor/plugins/action_mailer_optional_tls/test/tls_test.rb +0 -42
- data/src/head/wr_config.h +0 -165
- data/src/ruby_lib/mailer/action_mailer_tls.rb +0 -16
- data/src/ruby_lib/mailer/smtp_tls.rb +0 -123
data/src/helper/wr_scgi.c
CHANGED
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
#include "wr_logger.h"
|
|
29
29
|
|
|
30
30
|
#define SCGI_START_OFFSET 40
|
|
31
|
-
#define SCGI_CONTENT_LENGTH "CONTENT_LENGTH"
|
|
32
31
|
#define SCGI_CONTENT_LENGTH_LEN 14
|
|
33
32
|
|
|
34
33
|
#define SCGI_HEADER_BLOCK_SIZE 2048
|
|
@@ -109,7 +108,7 @@ int scgi_header_add(scgi_t* scgi, const char* field, size_t field_len, const cha
|
|
|
109
108
|
header->next = scgi->header_list;
|
|
110
109
|
scgi->header_list = header;
|
|
111
110
|
|
|
112
|
-
LOG_DEBUG(DEBUG, "%s:%s", scgi->header + header->field_offset, scgi->header + header->value_offset);
|
|
111
|
+
//LOG_DEBUG(DEBUG, "%s:%s", scgi->header + header->field_offset, scgi->header + header->value_offset);
|
|
113
112
|
|
|
114
113
|
return 0;
|
|
115
114
|
}
|
|
@@ -332,7 +331,7 @@ scgi_t* scgi_parse(const char *buffer, size_t length){
|
|
|
332
331
|
state = STATE_HEADER;
|
|
333
332
|
field_offset = i + 1;
|
|
334
333
|
field_len = value_len = 0;
|
|
335
|
-
LOG_DEBUG(DEBUG, "Header %s:%s", buffer + header->field_offset, buffer + header->value_offset);
|
|
334
|
+
//LOG_DEBUG(DEBUG, "Header %s:%s", buffer + header->field_offset, buffer + header->value_offset);
|
|
336
335
|
}
|
|
337
336
|
break;
|
|
338
337
|
case STATE_BODY: // Process request body
|
|
@@ -421,4 +420,4 @@ scgi_header_t* scgi_header_get(scgi_t* scgi, const char *field){
|
|
|
421
420
|
header = header->next;
|
|
422
421
|
}
|
|
423
422
|
return NULL;
|
|
424
|
-
}
|
|
423
|
+
}
|
data/src/helper/wr_scgi.h
CHANGED
data/src/helper/wr_string.h
CHANGED
|
@@ -36,8 +36,8 @@ typedef struct {
|
|
|
36
36
|
#define wr_string_is_empty(_str) _str.str == NULL
|
|
37
37
|
#define wr_string_new(_str,str1,_len) _str.len = _len; _str.str = (char*) malloc(sizeof(char)*(_len+1)); memcpy(_str.str, str1, _len); _str.str[_len] = 0
|
|
38
38
|
#define wr_string_null(_str) _str.len = 0; _str.str = NULL
|
|
39
|
-
#define wr_string_append(_str, str1, _len) char *str2 =(char*) realloc(_str.str,sizeof(char)*(_str.len+_len+1));\
|
|
40
|
-
if(str2){memcpy(str2+_str.len, str1, _len); _str.len+=_len;str2[_str.len]=0;_str.str=str2;}
|
|
39
|
+
#define wr_string_append(_str, str1, _len) {char *str2 =(char*) realloc(_str.str,sizeof(char)*(_str.len+_len+1));\
|
|
40
|
+
if(str2){memcpy(str2+_str.len, str1, _len); _str.len+=_len;str2[_str.len]=0;_str.str=str2;}}
|
|
41
41
|
#define wr_string_free(_str) if(_str.str) free(_str.str); _str.len = 0; _str.str = NULL
|
|
42
42
|
#define wr_string_dump(_str,_str1) _str.len = _str1.len;_str.str = (char*) malloc(sizeof(char)*(_str.len+1)); memcpy(_str.str, _str1.str, _str.len); _str.str[_str.len] = 0
|
|
43
43
|
|
data/src/helper/wr_util.c
CHANGED
|
@@ -138,7 +138,9 @@ time_t httpdate_to_c_time(const char *httpdate){
|
|
|
138
138
|
//LOG_DEBUG(DEBUG,"Counld not parse httpdate %s.", httpdate);
|
|
139
139
|
return -1;
|
|
140
140
|
}
|
|
141
|
-
|
|
141
|
+
|
|
142
|
+
//return mktime(&tm_info);
|
|
143
|
+
return timegm(&tm_info);
|
|
142
144
|
}
|
|
143
145
|
|
|
144
146
|
/** Convert C 'time_t' to HTTP date */
|
data/src/helper/wr_util.h
CHANGED
|
File without changes
|
data/src/helper/wr_yaml_parser.c
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
#include <stdlib.h>
|
|
25
25
|
#include <assert.h>
|
|
26
26
|
#include <wr_yaml_parser.h>
|
|
27
|
+
#include <wr_logger.h>
|
|
27
28
|
|
|
28
29
|
/** Free node */
|
|
29
30
|
void node_free(node_t* node) {
|
|
@@ -247,3 +248,32 @@ node_t* yaml_parse(const char*file_name) {
|
|
|
247
248
|
return NULL;
|
|
248
249
|
}
|
|
249
250
|
}
|
|
251
|
+
|
|
252
|
+
/** Validate YAML tokens */
|
|
253
|
+
char* wr_validate_string(const char* str) {
|
|
254
|
+
int count, len, is_blank, is_comment;
|
|
255
|
+
|
|
256
|
+
if(str == NULL)
|
|
257
|
+
return NULL;
|
|
258
|
+
|
|
259
|
+
//Set flags
|
|
260
|
+
is_blank = 1;
|
|
261
|
+
is_comment = 0;
|
|
262
|
+
len = strlen(str);
|
|
263
|
+
for(count = 0; count < len ; count++) {
|
|
264
|
+
//check for blank value
|
|
265
|
+
if(str[count] != ' ') {
|
|
266
|
+
is_blank = 0;
|
|
267
|
+
}
|
|
268
|
+
//check for comment '#' character
|
|
269
|
+
if(str[count] == '#') {
|
|
270
|
+
is_comment = 1;
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
if(is_comment || is_blank) {
|
|
275
|
+
LOG_ERROR(SEVERE,"Invalid token.");
|
|
276
|
+
return NULL;
|
|
277
|
+
}
|
|
278
|
+
return (char*)str;
|
|
279
|
+
}
|
data/src/helper/wr_yaml_parser.h
CHANGED
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
|
|
19
19
|
module Webroar
|
|
20
20
|
module ExceptionTracker
|
|
21
|
-
trace_rescue_action(:rescue_action, ActionController::Rescue, 'i')
|
|
21
|
+
trace_rescue_action(:rescue_action, ActionController::Rescue, 'i') if ::Rails::VERSION::MAJOR < 3
|
|
22
|
+
trace_rescue_action(:rescue_with_handler, ActionController::Base, 'i') if ::Rails::VERSION::MAJOR > 2
|
|
22
23
|
end # ExceptionTracker
|
|
23
24
|
end # Webroar
|
|
24
25
|
|
|
@@ -40,20 +40,23 @@ module Email
|
|
|
40
40
|
:password=>data['smtp']['password']}
|
|
41
41
|
from = data['smtp']['from']
|
|
42
42
|
recipients = data['smtp']['recipients']
|
|
43
|
-
ActionMailer::Base.smtp_settings = details
|
|
44
|
-
mail_configuration=true
|
|
43
|
+
ActionMailer::Base.smtp_settings = details
|
|
45
44
|
else
|
|
46
45
|
details ={:location=>data['sendmail']['location'],
|
|
47
46
|
:arguments=>"-i -t -f"}
|
|
48
47
|
from = data['sendmail']['from']
|
|
49
48
|
recipients = data['sendmail']['recipients']
|
|
50
|
-
ActionMailer::Base.sendmail_settings = details
|
|
51
|
-
mail_configuration=true
|
|
49
|
+
ActionMailer::Base.sendmail_settings = details
|
|
52
50
|
end
|
|
53
51
|
rescue
|
|
54
52
|
mail_configuration=false
|
|
55
53
|
nil
|
|
56
54
|
end
|
|
55
|
+
if data and data['email_notification'] and data['email_notification'].downcase == 'enabled'
|
|
56
|
+
mail_configuration = true
|
|
57
|
+
else
|
|
58
|
+
mail_configuration = false
|
|
59
|
+
end
|
|
57
60
|
return from,recipients,mail_configuration
|
|
58
61
|
end
|
|
59
62
|
class EmailHandler < ActionMailer::Base
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
|
|
19
19
|
module Webroar
|
|
20
20
|
module Profiler
|
|
21
|
-
trace_perform_action_equivalent(:perform_action, ActionController::Base, 'i')
|
|
21
|
+
trace_perform_action_equivalent(:perform_action, ActionController::Base, 'i') if ::Rails::VERSION::MAJOR < 3
|
|
22
|
+
trace_perform_action_equivalent(:process_action, ActionController::Base, 'i') if ::Rails::VERSION::MAJOR > 2
|
|
22
23
|
trace_render_equivalent(:render, ActionController::Base, 'i')
|
|
23
24
|
end # Profiler
|
|
24
25
|
end # Webroar
|
|
@@ -22,6 +22,9 @@ module Webroar
|
|
|
22
22
|
trace_database_method(:delete_all, ActiveRecord::Base, 'c')
|
|
23
23
|
trace_database_method(:save, ActiveRecord::Base, 'i')
|
|
24
24
|
trace_database_method(:destroy, ActiveRecord::Base, 'i')
|
|
25
|
+
trace_database_method(:all, ActiveRecord::Base, 'c') if ::Rails::VERSION::MAJOR > 2
|
|
26
|
+
trace_database_method(:first, ActiveRecord::Base, 'c') if ::Rails::VERSION::MAJOR > 2
|
|
27
|
+
trace_database_method(:last, ActiveRecord::Base, 'c') if ::Rails::VERSION::MAJOR > 2
|
|
25
28
|
|
|
26
29
|
# Comment out following lines, if you not interested in detailed analysis of ActiveRecord Models
|
|
27
30
|
# exclude_list = [Object, ActiveRecord::Base]
|
|
@@ -27,23 +27,30 @@ module Webroar
|
|
|
27
27
|
|
|
28
28
|
@rails_app = if defined?(ActionController::Dispatcher) and ActionController::Dispatcher.instance_methods.include?('call')
|
|
29
29
|
ActionController::Dispatcher.new
|
|
30
|
+
elsif ::Rails::VERSION::MAJOR >= 3
|
|
31
|
+
::Rails.application
|
|
30
32
|
else
|
|
31
33
|
CgiApp.new
|
|
32
34
|
end
|
|
33
35
|
|
|
34
|
-
@file_server = ::Rack::File.new(::File.join(
|
|
36
|
+
@file_server = ::Rack::File.new(::File.join(@root, "public"))
|
|
35
37
|
end
|
|
36
38
|
|
|
37
39
|
def load_application
|
|
38
40
|
ENV['RAILS_ENV'] = @env
|
|
39
41
|
|
|
40
42
|
require "#{@root}/config/environment"
|
|
41
|
-
|
|
42
|
-
if
|
|
43
|
-
|
|
44
|
-
else
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
# TODO: figure out way to set relative URL, following is not working on Rails3-beta4 for stylesheet_link_tag, javascript_include_tag
|
|
44
|
+
if ::Rails::VERSION::MAJOR >= 3
|
|
45
|
+
::Rails.application.config.relative_url_root = @prefix
|
|
46
|
+
else
|
|
47
|
+
require 'dispatcher'
|
|
48
|
+
if ActionController::Base.respond_to?('relative_url_root=')
|
|
49
|
+
ActionController::Base.relative_url_root = @prefix # new way to set the relative URL in Rails 2.1.1
|
|
50
|
+
else
|
|
51
|
+
ActionController::AbstractRequest.relative_url_root = @prefix
|
|
52
|
+
end
|
|
53
|
+
end
|
|
47
54
|
end
|
|
48
55
|
|
|
49
56
|
# TODO refactor this in File#can_serve?(path) ??
|
|
@@ -51,12 +51,14 @@ begin
|
|
|
51
51
|
# STDERR.sync = true
|
|
52
52
|
# puts '...........file opened..............'
|
|
53
53
|
require File.join(File.dirname(__FILE__), 'profiler', 'message_dispatcher') #to send pid of worker
|
|
54
|
-
|
|
54
|
+
# TODO: Add Exception tracking for Rails 3
|
|
55
|
+
if $pid_sent and $g_options["app_name"].strip != 'Admin Panel' and $g_options["app_type"] == "rails"
|
|
55
56
|
require File.join(File.dirname(__FILE__), 'exception_tracker', 'webroar_exception.rb')
|
|
56
57
|
else
|
|
57
58
|
Webroar.log_info("Exception notification would not work.")
|
|
58
59
|
end
|
|
59
|
-
|
|
60
|
+
# TODO: Add profiling support for Rails 3
|
|
61
|
+
if $g_options["app_profiling"] == "yes" and $g_options["app_type"] == "rails"
|
|
60
62
|
if $pid_sent
|
|
61
63
|
require File.expand_path(File.join($g_options["webroar_root"], 'src', 'ruby_lib', 'profiler', 'webroar_profiling.rb'))
|
|
62
64
|
else
|