webroar 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +34 -0
- data/lib/dependencies.rb +9 -7
- data/lib/installer.rb +46 -18
- data/src/admin_panel/app/controllers/graph_controller.rb +2 -2
- data/src/admin_panel/app/views/graph/_javascript_partial.html.erb +1 -0
- data/src/admin_panel/lib/yaml_writer.rb +1 -1
- data/src/head/wr_application.c +2 -3
- data/src/head/wr_application.h +2 -2
- data/src/head/wr_config.h +2 -1
- data/src/head/wr_configurator.c +3 -10
- data/src/head/wr_connection.c +11 -10
- data/src/head/wr_controller.c +2 -6
- data/src/head/wr_main.c +2 -2
- data/src/head/wr_request.c +2 -5
- data/src/head/wr_resolver.c +2 -2
- data/src/head/wr_server.c +0 -2
- data/src/head/wr_worker.c +0 -4
- data/src/helper/wr_logger.c +5 -8
- data/src/helper/wr_logger.h +2 -2
- data/src/helper/wr_yaml_parser.c +1 -1
- data/src/ruby_lib/ruby_interface/client.rb +9 -2
- data/src/ruby_lib/ruby_interface/constants.rb +1 -0
- data/src/ruby_lib/ruby_interface/deflater.rb +28 -91
- data/src/ruby_lib/ruby_interface/logger.rb +3 -3
- data/src/ruby_lib/ruby_interface/request_handler.rb +23 -8
- data/src/ruby_lib/ruby_interface/utils.rb +17 -6
- data/src/ruby_lib/ruby_interface/version.rb +1 -1
- data/src/ruby_lib/webroar_app_loader.rb +2 -2
- data/src/worker/wkr_http.c +6 -6
- data/src/worker/wkr_http_response.c +8 -5
- data/src/worker/wkr_main.c +3 -3
- data/src/worker/wkr_static.c +5 -8
- data/src/worker/wkr_static.h +1 -1
- data/test/spec/content_encoding_spec.rb +14 -0
- metadata +2 -24
- data/src/admin_panel/public/blank_iframe.html +0 -2
- data/src/admin_panel/public/images/calendar_date_select/calendar.gif +0 -0
- data/src/admin_panel/public/javascripts/calendar_date_select/calendar_date_select.js +0 -443
- data/src/admin_panel/public/javascripts/calendar_date_select/format_american.js +0 -34
- data/src/admin_panel/public/javascripts/calendar_date_select/format_db.js +0 -27
- data/src/admin_panel/public/javascripts/calendar_date_select/format_euro_24hr.js +0 -7
- data/src/admin_panel/public/javascripts/calendar_date_select/format_euro_24hr_ymd.js +0 -7
- data/src/admin_panel/public/javascripts/calendar_date_select/format_finnish.js +0 -32
- data/src/admin_panel/public/javascripts/calendar_date_select/format_hyphen_ampm.js +0 -37
- data/src/admin_panel/public/javascripts/calendar_date_select/format_iso_date.js +0 -46
- data/src/admin_panel/public/javascripts/calendar_date_select/format_italian.js +0 -24
- data/src/admin_panel/public/javascripts/calendar_date_select/locale/de.js +0 -11
- data/src/admin_panel/public/javascripts/calendar_date_select/locale/fi.js +0 -10
- data/src/admin_panel/public/javascripts/calendar_date_select/locale/fr.js +0 -10
- data/src/admin_panel/public/javascripts/calendar_date_select/locale/pl.js +0 -10
- data/src/admin_panel/public/javascripts/calendar_date_select/locale/pt.js +0 -11
- data/src/admin_panel/public/javascripts/calendar_date_select/locale/ru.js +0 -10
- data/src/admin_panel/public/stylesheets/calendar_date_select/blue.css +0 -130
- data/src/admin_panel/public/stylesheets/calendar_date_select/default.css +0 -135
- data/src/admin_panel/public/stylesheets/calendar_date_select/plain.css +0 -128
- data/src/admin_panel/public/stylesheets/calendar_date_select/red.css +0 -135
- data/src/admin_panel/public/stylesheets/calendar_date_select/silver.css +0 -133
data/CHANGELOG
CHANGED
@@ -1,3 +1,37 @@
|
|
1
|
+
v0.2.6 - 23-Dec-2009
|
2
|
+
--------------------
|
3
|
+
|
4
|
+
* Updated messages for HTTP status codes 400, 404, 405, 500 and 501.
|
5
|
+
* Fixed buffer overflow by allocating enough memory to hold REQUEST_PATH +
|
6
|
+
Application-Path in the request resolver for static assets.
|
7
|
+
* Improved the logic for detection of ruby shared library prerequisite.
|
8
|
+
* Started using RUBY_INSTALL_NAME for detecting ruby during installation.
|
9
|
+
* Added validation for search results file created while generating service
|
10
|
+
script. Installation would continue even if server cannot be installed as a
|
11
|
+
service.
|
12
|
+
* Corrected example for 'Headers' section in the config file.
|
13
|
+
* Removed 'SIGCHLD' handler from the worker process - Fixes the incorrect exit
|
14
|
+
status issue for a shell command executed using backquote method of ruby.
|
15
|
+
* Added HTTP Date header when the HTTP response status is 100.
|
16
|
+
* Used _POSIX_C_SOURCE macro to identify whether the file variable is a
|
17
|
+
pointer to a file or a socket fd.
|
18
|
+
* Corrected return type of 'send_static_worker_pid' method, if YAML parser
|
19
|
+
returns NULL value.
|
20
|
+
* Corrected time slider based analytics graphs issue when they were being seen
|
21
|
+
after 2300 hrs.
|
22
|
+
* Correctly implemented Rack specification for the Response Body. This fixes
|
23
|
+
worker crash seen after serving first request in Development Environment mode
|
24
|
+
for Rails 2.3.4+ applications.
|
25
|
+
* Overriding Rack::Deflater to skip response body compression for user-agent
|
26
|
+
Internet Explorer 6.0.
|
27
|
+
* Renamed 'log' message defined by rb_define_singleton_method() to
|
28
|
+
'log_message'. This fixes the issue seen when Math.log is called by
|
29
|
+
number_to_human_size() in a Rails Application. It also fixes the worker crash
|
30
|
+
on REE installed with tcmalloc library. (Typically used to result in 404 error
|
31
|
+
for a user trying to access the Admin Panel.) Resolves Tickets #9 and #10.
|
32
|
+
* Code cleanup in Head, Worker and Helper modules.
|
33
|
+
|
34
|
+
|
1
35
|
v0.2.5 - 07-Dec-2009
|
2
36
|
--------------------
|
3
37
|
|
data/lib/dependencies.rb
CHANGED
@@ -37,7 +37,7 @@ module Webroar
|
|
37
37
|
def find
|
38
38
|
name = @name
|
39
39
|
case (name)
|
40
|
-
when CONFIG['CC'], "make", CONFIG['
|
40
|
+
when Config::CONFIG['CC'], "make", Config::CONFIG['RUBY_INSTALL_NAME'], "starling"; flag = find_command(name)
|
41
41
|
when "libsqlite3.so", "sqlite3.h", "gnutls/gnutls.h"; flag = find_so(name)
|
42
42
|
when "ruby_headers"; flag = find_ruby_headers()
|
43
43
|
when "openssl.so"; flag = find_openssl(name)
|
@@ -51,11 +51,13 @@ module Webroar
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def find_shared_lib()
|
54
|
-
if Config::CONFIG['
|
55
|
-
flag = "\e[32mfound\e[0m."
|
54
|
+
if File.exist?(File.join(Config::CONFIG['libdir'],Config::CONFIG['LIBRUBY_SO']))
|
55
|
+
flag = "\e[32mfound\e[0m at #{Config::CONFIG['libdir']}."
|
56
|
+
elsif Config::CONFIG['ENABLE_SHARED'] == 'yes'
|
57
|
+
flag = "\e[32mfound\e[0m."
|
56
58
|
else
|
57
|
-
flag="\e[31mnot found\e[0m."
|
58
|
-
end
|
59
|
+
flag="\e[31mnot found\e[0m.\nUnable to find #{Config::CONFIG['LIBRUBY_SO']} at #{Config::CONFIG['libdir']}."
|
60
|
+
end
|
59
61
|
return flag
|
60
62
|
end
|
61
63
|
|
@@ -160,13 +162,13 @@ module Webroar
|
|
160
162
|
|
161
163
|
end
|
162
164
|
module Dependencies
|
163
|
-
GCC = Dependency.new(CONFIG['CC'])
|
165
|
+
GCC = Dependency.new(Config::CONFIG['CC'])
|
164
166
|
Gnutls = Dependency.new('gnutls/gnutls.h')
|
165
167
|
Make = Dependency.new('make')
|
166
168
|
LibRuby = Dependency.new(Config::CONFIG['LIBRUBY_SO'])
|
167
169
|
LibSqlite = Dependency.new('libsqlite3.so')
|
168
170
|
Ruby_OpenSSL = Dependency.new('openssl-ruby')
|
169
|
-
Ruby = Dependency.new(CONFIG['
|
171
|
+
Ruby = Dependency.new(Config::CONFIG['RUBY_INSTALL_NAME'])
|
170
172
|
Ruby_DevHeaders = Dependency.new('ruby_headers')
|
171
173
|
RubyGems = Dependency.new('rubygems')
|
172
174
|
Sqlite_DevHeaders = Dependency.new('sqlite3.h')
|
data/lib/installer.rb
CHANGED
@@ -91,19 +91,28 @@ class Installer
|
|
91
91
|
|
92
92
|
def create_service_link(level, link_name, script_file)
|
93
93
|
system("find /etc/ -name rc#{level}.d > /tmp/search_result 2>>#{WEBROAR_ROOT}/install.log")
|
94
|
+
|
95
|
+
return false if !File.size?("/tmp/search_result")
|
96
|
+
|
94
97
|
file = File.open("/tmp/search_result")
|
95
98
|
line = file.readline.chomp
|
96
99
|
file.close()
|
100
|
+
|
101
|
+
return false if line == nil
|
102
|
+
|
97
103
|
link_file = File.join(line,link_name)
|
98
104
|
|
99
|
-
if
|
105
|
+
if script_file != nil and !File.symlink?(link_file)
|
100
106
|
system("ln -s #{script_file} #{link_file} >>#{WEBROAR_ROOT}/install.log 2>>#{WEBROAR_ROOT}/install.log")
|
101
107
|
end
|
108
|
+
|
109
|
+
return true
|
102
110
|
end
|
103
111
|
|
104
112
|
def create_service
|
105
113
|
script = nil
|
106
114
|
script_file = nil
|
115
|
+
|
107
116
|
if(check_exe_file("chkconfig"))
|
108
117
|
script = get_service_script("# chkconfig: 2345 85 15")
|
109
118
|
else
|
@@ -111,24 +120,32 @@ class Installer
|
|
111
120
|
end
|
112
121
|
|
113
122
|
system("find /etc/ -name init.d > /tmp/search_result 2>>#{WEBROAR_ROOT}/install.log")
|
123
|
+
|
124
|
+
return false if !File.size?("/tmp/search_result")
|
125
|
+
|
114
126
|
file = File.open("/tmp/search_result")
|
115
127
|
line = file.readline.chomp
|
116
128
|
file.close()
|
117
|
-
if line != nil
|
118
|
-
script_file = File.join("#{line}",'webroar')
|
119
|
-
file = File.open(script_file,"w")
|
120
|
-
file.puts(script)
|
121
|
-
file.close
|
122
|
-
system("chmod +x #{script_file} 2>>#{WEBROAR_ROOT}/install.log")
|
123
|
-
end
|
124
129
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
130
|
+
return false if line == nil
|
131
|
+
|
132
|
+
script_file = File.join("#{line}",'webroar')
|
133
|
+
|
134
|
+
file = File.open(script_file,"w")
|
135
|
+
file.puts(script)
|
136
|
+
file.close
|
137
|
+
|
138
|
+
system("chmod +x #{script_file} 2>>#{WEBROAR_ROOT}/install.log")
|
139
|
+
|
140
|
+
return false if !create_service_link("0", 'K15webroar', script_file)
|
141
|
+
return false if !create_service_link("1", 'K15webroar', script_file)
|
142
|
+
return false if !create_service_link("6", 'K15webroar', script_file)
|
143
|
+
return false if !create_service_link("2", 'S85webroar', script_file)
|
144
|
+
return false if !create_service_link("3", 'S85webroar', script_file)
|
145
|
+
return false if !create_service_link("4", 'S85webroar', script_file)
|
146
|
+
return false if !create_service_link("5", 'S85webroar', script_file)
|
147
|
+
|
148
|
+
return true
|
132
149
|
|
133
150
|
end
|
134
151
|
|
@@ -142,6 +159,7 @@ class Installer
|
|
142
159
|
def install(options, args)
|
143
160
|
ssl = false
|
144
161
|
str = ""
|
162
|
+
err_msg = nil
|
145
163
|
|
146
164
|
if options[:ssl]
|
147
165
|
ssl = true
|
@@ -225,8 +243,17 @@ class Installer
|
|
225
243
|
if RUBY_PLATFORM =~ /linux/ and !import
|
226
244
|
print "Generating service script ..."
|
227
245
|
# Add service script in '/etc/init.d/' folder
|
228
|
-
create_service()
|
229
|
-
|
246
|
+
if create_service()
|
247
|
+
puts " done."
|
248
|
+
else
|
249
|
+
puts " failed."
|
250
|
+
tmp_msg = "The server could not be installed as a service on this system. Unfortunately, you would have to set it up as a service yourself."
|
251
|
+
if err_msg
|
252
|
+
err_msg += tmp_msg
|
253
|
+
else
|
254
|
+
err_msg = tmp_msg
|
255
|
+
end
|
256
|
+
end
|
230
257
|
end
|
231
258
|
|
232
259
|
puts"WebROaR installed successfully."
|
@@ -239,6 +266,7 @@ class Installer
|
|
239
266
|
system("webroar start")
|
240
267
|
|
241
268
|
install_msg(port, false)
|
269
|
+
puts "Warning: " + err_msg if err_msg
|
242
270
|
else
|
243
271
|
puts " failed."
|
244
272
|
puts "Error while migrating sqlite database. Please refer 'install.log' for details"
|
@@ -600,7 +628,7 @@ exit 0"
|
|
600
628
|
# II) Expires value(mandatory) (No of seconds)
|
601
629
|
# Possible value for expires is off or no. of seconds.
|
602
630
|
# Example:
|
603
|
-
#
|
631
|
+
# Headers:
|
604
632
|
# expires: 3600
|
605
633
|
# expires_by_type:
|
606
634
|
# - ext: png, jpg, gif
|
@@ -369,7 +369,7 @@ class GraphController < ApplicationController
|
|
369
369
|
date_str = date_arr[0].split("/")
|
370
370
|
start_hour = date_str[3]
|
371
371
|
date_str1 = date_arr[1].split("/")
|
372
|
-
end_hour = date_str1[3]
|
372
|
+
end_hour = (date_str1[3] == "0" ? "24" : date_str1[3])
|
373
373
|
if start_hour.to_i != end_hour.to_i
|
374
374
|
end_hour = end_hour.to_i-1
|
375
375
|
start_time = Time.local(date_str[0], date_str[1], date_str[2], start_hour, "00", "00")
|
@@ -588,7 +588,7 @@ class GraphController < ApplicationController
|
|
588
588
|
if session[:start_time] < Time.local(Time.now.year, Time.now.month, Time.now.day, "0","0","0")
|
589
589
|
end_hour = 24
|
590
590
|
else
|
591
|
-
|
591
|
+
end_hour = (Time.now.advance(:hours => 1)).hour
|
592
592
|
end
|
593
593
|
start_time = "#{session[:start_time].year}/#{session[:start_time].month}/#{session[:start_time].day}/#{start_hour}"
|
594
594
|
end_time = "#{session[:start_time].year}/#{session[:start_time].month}/#{session[:start_time].day}/#{end_hour}"
|
data/src/head/wr_application.c
CHANGED
@@ -92,7 +92,6 @@ void wr_app_wrk_add_timeout_cb(struct ev_loop *loop, ev_timer *w, int revents) {
|
|
92
92
|
void wr_app_wrk_remove_cb(struct ev_loop *loop, ev_timer *w, int revents) {
|
93
93
|
LOG_FUNCTION
|
94
94
|
wr_app_t* app = (wr_app_t*) w->data;
|
95
|
-
wr_wkr_t* worker;
|
96
95
|
|
97
96
|
ev_timer_stop(loop, &app->t_remove);
|
98
97
|
|
@@ -439,7 +438,7 @@ int wr_app_remove(wr_svr_t* server, const char* app_name) {
|
|
439
438
|
}
|
440
439
|
|
441
440
|
/** Check load balance to add the worker */
|
442
|
-
|
441
|
+
void wr_app_chk_load_to_add_wkr(wr_app_t *app) {
|
443
442
|
if(TOTAL_WORKER_COUNT(app) < app->conf->max_worker) {
|
444
443
|
if(app->msg_que->q_count > app->high_ratio) {
|
445
444
|
if(!ev_is_active(&app->t_add)) {
|
@@ -454,7 +453,7 @@ int wr_app_chk_load_to_add_wkr(wr_app_t *app) {
|
|
454
453
|
}
|
455
454
|
|
456
455
|
/** Check load balance to remove the worker */
|
457
|
-
|
456
|
+
void wr_app_chk_load_to_remove_wkr(wr_app_t *app) {
|
458
457
|
//Check load
|
459
458
|
if(WR_QUEUE_SIZE(app->wkr_que) > app->conf->min_worker) {
|
460
459
|
if(app->msg_que->q_count < app->low_ratio) {
|
data/src/head/wr_application.h
CHANGED
@@ -61,9 +61,9 @@ int wr_app_wkr_add(wr_app_t*);
|
|
61
61
|
/** Add request message in pending queue */
|
62
62
|
int wr_app_message_insert(wr_svr_t*, wr_req_t*);
|
63
63
|
/** Check load balance to add the worker */
|
64
|
-
|
64
|
+
void wr_app_chk_load_to_add_wkr(wr_app_t*);
|
65
65
|
/** Check load balance to remove the worker */
|
66
|
-
|
66
|
+
void wr_app_chk_load_to_remove_wkr(wr_app_t*);
|
67
67
|
/** Add newly created worker to application */
|
68
68
|
int wr_app_wrk_insert(wr_svr_t *, wr_wkr_t*, const wr_ctl_msg_t*);
|
69
69
|
/** Remove application from application list */
|
data/src/head/wr_config.h
CHANGED
@@ -81,7 +81,7 @@
|
|
81
81
|
// File to store Server process id
|
82
82
|
#define WR_PID_FILE "/var/run/webroar.pid"
|
83
83
|
#define WR_SERVER "WebROaR"
|
84
|
-
#define WR_VERSION "0.2.
|
84
|
+
#define WR_VERSION "0.2.6"
|
85
85
|
#define WR_MIME_TYPE_PATH "/conf/mime_type.yml"
|
86
86
|
#define WR_CONF_PATH "/conf/config.yml"
|
87
87
|
#define WR_SERVER_INTERNAL_CONF_PATH "/conf/server_internal_config.yml"
|
@@ -124,6 +124,7 @@
|
|
124
124
|
#define WR_STR_LEN 64
|
125
125
|
#define WR_LONG_STR_LEN 128
|
126
126
|
#define WR_LONG_LONG_STR_LEN 512
|
127
|
+
#define WR_FILE_PATH_LEN 1024
|
127
128
|
|
128
129
|
#define WR_DEFAULT_PREFIX_HASH 5381
|
129
130
|
#define WR_MSG_SIZE 1024
|
data/src/head/wr_configurator.c
CHANGED
@@ -83,9 +83,6 @@ static inline wr_app_conf_t* wr_app_conf_new(wr_svr_conf_t *server) {
|
|
83
83
|
/** Create new configuration with default values */
|
84
84
|
static inline wr_conf_t* wr_conf_new() {
|
85
85
|
LOG_FUNCTION
|
86
|
-
int i;
|
87
|
-
wr_svr_conf_t *server;
|
88
|
-
wr_app_conf_t *app;
|
89
86
|
wr_conf_t *conf;
|
90
87
|
|
91
88
|
conf = wr_malloc(wr_conf_t);
|
@@ -205,7 +202,6 @@ static inline int wr_conf_server_set(wr_conf_t * conf, node_t *root) {
|
|
205
202
|
LOG_FUNCTION
|
206
203
|
wr_svr_conf_t *server = conf->server;
|
207
204
|
char *str;
|
208
|
-
size_t len;
|
209
205
|
|
210
206
|
// Set server listening port
|
211
207
|
str = wr_validate_string(get_node_value(root, WR_CONF_SVR_PORT));
|
@@ -255,6 +251,7 @@ static inline int wr_conf_server_set(wr_conf_t * conf, node_t *root) {
|
|
255
251
|
#ifdef HAVE_GNUTLS
|
256
252
|
|
257
253
|
if(server->flag&WR_SVR_SSL_SUPPORT) {
|
254
|
+
size_t len;
|
258
255
|
struct stat buff;
|
259
256
|
// Set certificate path
|
260
257
|
str = wr_validate_string(get_node_value(root, WR_CONF_SVR_SSL_CERTIFICATE));
|
@@ -311,7 +308,7 @@ static inline int wr_conf_server_set(wr_conf_t * conf, node_t *root) {
|
|
311
308
|
|
312
309
|
static int wr_validate_app_host_name(const char *host_name, char *err_msg) {
|
313
310
|
LOG_FUNCTION
|
314
|
-
int down_level = 1, label_len,
|
311
|
+
int down_level = 1, label_len, i;
|
315
312
|
char *label = NULL;
|
316
313
|
char tmp_host[256];
|
317
314
|
size_t len;
|
@@ -754,8 +751,7 @@ static inline int wr_chk_host_lists(wr_host_name_t *list1, wr_host_name_t *list2
|
|
754
751
|
/** Removes Application object on repeated host_name. */
|
755
752
|
static inline int wr_remove_app_with_dup_host(wr_conf_t *conf) {
|
756
753
|
LOG_FUNCTION
|
757
|
-
wr_app_conf_t *app=conf->apps, *tmp_app = NULL
|
758
|
-
wr_host_name_t *host, *tmp_host, *next_host;
|
754
|
+
wr_app_conf_t *app=conf->apps, *tmp_app = NULL;
|
759
755
|
short rv = 0;
|
760
756
|
|
761
757
|
if(app == NULL) {
|
@@ -1040,10 +1036,7 @@ void wr_conf_free(wr_conf_t* conf) {
|
|
1040
1036
|
wr_conf_t* wr_conf_read(const char* root_path) {
|
1041
1037
|
LOG_FUNCTION
|
1042
1038
|
node_t *root;
|
1043
|
-
char *str;
|
1044
1039
|
wr_conf_t* conf = NULL;
|
1045
|
-
int can_start = 1;
|
1046
|
-
struct stat buff;
|
1047
1040
|
|
1048
1041
|
//Create configuration structure
|
1049
1042
|
conf = wr_conf_new();
|
data/src/head/wr_connection.c
CHANGED
@@ -31,15 +31,15 @@ wr_http_status_t;
|
|
31
31
|
|
32
32
|
static wr_http_status_t http_status [] ={
|
33
33
|
{100, "100 Continue", ""},
|
34
|
-
{400, "400 Bad Request", "The request could not be understood by the server."},
|
34
|
+
{400, "400 Bad Request", "The request could not be understood by the server due to malformed syntax."},
|
35
35
|
{403, "403 Forbidden", "The requested page is forbidden."},
|
36
|
-
{404, "404 Not Found", "The
|
37
|
-
{405, "405 Method Not Allowed", "The
|
36
|
+
{404, "404 Not Found", "The server has not found anything matching the Request-URI."},
|
37
|
+
{405, "405 Method Not Allowed", "The method specified in the Request-Line is not allowed for the resource identified by the Request-URI."},
|
38
38
|
{411, "411 Length Required", "The request requires 'Content-Length'."},
|
39
39
|
{413, "413 Request Entity Too Large", "The request entity is too large"},
|
40
40
|
{414, "414 Request-URI Too Large", "The request URI is too large"},
|
41
|
-
{500, "500 Internal Server Error", "The server
|
42
|
-
{501, "501 Not Implemented", "The
|
41
|
+
{500, "500 Internal Server Error", "The server encountered an unexpected condition which prevented it from fulfilling the request."},
|
42
|
+
{501, "501 Not Implemented", "The server does not support the functionality required to fulfill the request."}
|
43
43
|
};
|
44
44
|
|
45
45
|
#define WR_RESP_BODY "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n\
|
@@ -257,13 +257,16 @@ void wr_conn_err_resp(wr_conn_t *conn, wr_resp_status_t resp_code) {
|
|
257
257
|
|
258
258
|
LOG_DEBUG(DEBUG, "response code = %s",http_status[resp_code].phrase);
|
259
259
|
conn->keep_alive = 0;
|
260
|
+
|
261
|
+
char current_date[WR_STR_LEN];
|
262
|
+
get_time(current_date, WR_STR_LEN);
|
260
263
|
|
261
264
|
switch(resp_code) {
|
262
265
|
case WR_HTTP_STATUS_100:
|
263
266
|
body_len = 0;
|
264
267
|
buff_len = sprintf(response_buff, WR_RESP_HEADERS,
|
265
|
-
http_status[resp_code].phrase, WR_SERVER,
|
266
|
-
body_len, http_status[resp_code].message);
|
268
|
+
http_status[resp_code].phrase, current_date, WR_SERVER,
|
269
|
+
WR_VERSION, body_len, http_status[resp_code].message);
|
267
270
|
break;
|
268
271
|
case WR_HTTP_STATUS_400:
|
269
272
|
case WR_HTTP_STATUS_403:
|
@@ -285,9 +288,7 @@ void wr_conn_err_resp(wr_conn_t *conn, wr_resp_status_t resp_code) {
|
|
285
288
|
http_status[resp_code].phrase,http_status[resp_code].phrase+4,
|
286
289
|
http_status[resp_code].message,WR_SERVER, WR_VERSION);
|
287
290
|
}
|
288
|
-
|
289
|
-
char current_date[WR_STR_LEN];
|
290
|
-
get_time(current_date, WR_STR_LEN);
|
291
|
+
|
291
292
|
buff_len = sprintf(response_buff, WR_RESP_HEADERS,
|
292
293
|
http_status[resp_code].phrase, current_date,
|
293
294
|
WR_SERVER, WR_VERSION, body_len, response_body);
|
data/src/head/wr_controller.c
CHANGED
@@ -53,7 +53,7 @@
|
|
53
53
|
static inline wr_ctl_msg_t* wr_ctl_msg_validate(scgi_t* request, wr_ctl_t* ctl) {
|
54
54
|
LOG_FUNCTION
|
55
55
|
wr_ctl_msg_t* ctl_msg = wr_malloc(wr_ctl_msg_t);
|
56
|
-
char *val
|
56
|
+
char *val;
|
57
57
|
char error[WR_STR_LEN];
|
58
58
|
|
59
59
|
ctl->type = WR_CTL_MSG_NONE;
|
@@ -346,11 +346,8 @@ static void wr_ctl_accept_cb(struct ev_loop *loop, struct ev_io *w, int revents)
|
|
346
346
|
/** Start listening for Workers connect request on Internet socket */
|
347
347
|
static inline int wr_ctl_init_on_inet_sock(wr_svr_t *server) {
|
348
348
|
LOG_FUNCTION
|
349
|
-
struct linger ling = {
|
350
|
-
0, 0
|
351
|
-
};
|
352
349
|
struct sockaddr_in addr;
|
353
|
-
int
|
350
|
+
int len;
|
354
351
|
|
355
352
|
if ((server->ctl->fd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
|
356
353
|
perror("socket()");
|
@@ -422,7 +419,6 @@ static inline int wr_ctl_init_on_uds(wr_svr_t *server) {
|
|
422
419
|
|
423
420
|
/* Preparing unique controller socket path*/
|
424
421
|
pid_t pid=getpid();
|
425
|
-
char pid_str[WR_SHORT_STR_LEN];
|
426
422
|
sprintf(sock_path,"%s_%d",WR_CTL_SOCK_PATH,pid);
|
427
423
|
size_t len = strlen(sock_path);
|
428
424
|
|
data/src/head/wr_main.c
CHANGED
@@ -110,7 +110,7 @@ static inline void daemonize() {
|
|
110
110
|
/* first instance continues */
|
111
111
|
sprintf(str,"%d\n",getpid());
|
112
112
|
|
113
|
-
|
113
|
+
write(pid_FD,str,strlen(str)); /* record pid to lockfile */
|
114
114
|
close(pid_FD);
|
115
115
|
|
116
116
|
signal(SIGCHLD, SIG_IGN);
|
@@ -206,7 +206,7 @@ int main(int argc, char *argv[]) {
|
|
206
206
|
char *WR_ROOT = argv[1];
|
207
207
|
|
208
208
|
//Initialize logger
|
209
|
-
if(initialize_logger(WR_LOG_FILE) == 0) {
|
209
|
+
if(initialize_logger(WR_LOG_FILE, WR_SERVER, WR_VERSION) == 0) {
|
210
210
|
LOG_DEBUG(DEBUG,"Logging started in %s file",WR_LOG_FILE);
|
211
211
|
} else {
|
212
212
|
printf("Logger initialization failed. Please make sure you have write permission on '/var/log/webroar' directory.");
|
data/src/head/wr_request.c
CHANGED
@@ -66,7 +66,7 @@ static inline int wr_req_path_set(wr_req_t *req) {
|
|
66
66
|
LOG_DEBUG(DEBUG,"query str len = %d", req->req_query_str.len);
|
67
67
|
req->resp_buf_len = sprintf(req->resp_buf,"%s","The request query string is too large.");
|
68
68
|
wr_req_invalid(req->conn, WR_HTTP_STATUS_413);
|
69
|
-
return;
|
69
|
+
return -1;
|
70
70
|
}
|
71
71
|
|
72
72
|
// Set host and request path
|
@@ -91,7 +91,7 @@ static inline int wr_req_path_set(wr_req_t *req) {
|
|
91
91
|
LOG_DEBUG(DEBUG,"req path len = %d", req->req_path.len);
|
92
92
|
req->resp_buf_len = sprintf(req->resp_buf,"%s","The request path is too large.");
|
93
93
|
wr_req_invalid(req->conn, WR_HTTP_STATUS_413);
|
94
|
-
return;
|
94
|
+
return -1;
|
95
95
|
}
|
96
96
|
} else {
|
97
97
|
host_len = req->req_uri.len - (ptr - req->req_uri.str);
|
@@ -179,7 +179,6 @@ static int wr_req_header_length_check(wr_req_t *req, size_t length, int index){
|
|
179
179
|
void wr_req_header_field_cb(ebb_request* request, const char *at, size_t length, int header_index) {
|
180
180
|
wr_req_t* req = (wr_req_t*) request->data;
|
181
181
|
short status = wr_req_header_length_check(req, length, header_index);
|
182
|
-
size_t i;
|
183
182
|
|
184
183
|
if(status != 0){
|
185
184
|
wr_req_invalid(req->conn, status);
|
@@ -264,7 +263,6 @@ void wr_query_string_cb(ebb_request* request, const char *at, size_t length) {
|
|
264
263
|
void wr_req_uri_cb(ebb_request* request, const char *at, size_t length) {
|
265
264
|
LOG_FUNCTION
|
266
265
|
wr_req_t* req =(wr_req_t*) request->data;
|
267
|
-
char *value=NULL;
|
268
266
|
|
269
267
|
if(req->req_uri.len + length > WR_MAX_REQ_URI_LEN) {
|
270
268
|
LOG_DEBUG(DEBUG,"req uri len = %d",__FUNCTION__, req->req_uri.len);
|
@@ -457,7 +455,6 @@ void wr_headers_complete_cb(ebb_request * request) {
|
|
457
455
|
void wr_req_complete_cb(ebb_request * request) {
|
458
456
|
LOG_FUNCTION
|
459
457
|
wr_req_t* req = (wr_req_t*) request->data;
|
460
|
-
short retval;
|
461
458
|
LOG_DEBUG(DEBUG,"req = %d",req->id);
|
462
459
|
// Rewind file pointer if request body is written into file
|
463
460
|
if(req->upload_file) {
|
data/src/head/wr_resolver.c
CHANGED
@@ -43,7 +43,7 @@ void wr_req_resolver_print(wr_req_resolver_t* resolver) {
|
|
43
43
|
/** Resolve static content */
|
44
44
|
int wr_req_resolve_static_content(wr_req_t *req){
|
45
45
|
LOG_FUNCTION
|
46
|
-
char path[
|
46
|
+
char path[WR_FILE_PATH_LEN + WR_MAX_REQ_PATH_LEN];
|
47
47
|
char *req_path;
|
48
48
|
struct stat buf;
|
49
49
|
int len;
|
@@ -297,7 +297,7 @@ int wr_req_resolve_http_req(wr_svr_t *server, wr_req_t *req) {
|
|
297
297
|
}
|
298
298
|
|
299
299
|
if(app && app->wkr_que->q_count > 0) {
|
300
|
-
int rv = 0;
|
300
|
+
// int rv = 0;
|
301
301
|
req->app = app;
|
302
302
|
wr_req_resolve_static_content(req);
|
303
303
|
LOG_DEBUG(DEBUG,"Application resolved with %s.", req->app->conf->name.str);
|
data/src/head/wr_server.c
CHANGED
@@ -25,7 +25,6 @@ struct ev_idle idle_watcher; //Ideal watcher
|
|
25
25
|
/** Create Server */
|
26
26
|
wr_svr_t* wr_svr_new(struct ev_loop* loop, wr_conf_t* conf) {
|
27
27
|
LOG_FUNCTION
|
28
|
-
int i;
|
29
28
|
wr_svr_t* server = wr_malloc(wr_svr_t);
|
30
29
|
|
31
30
|
if(!server) {
|
@@ -163,7 +162,6 @@ int wr_svr_init(wr_svr_t** server, wr_conf_t *conf) {
|
|
163
162
|
/** Destroy Server */
|
164
163
|
void wr_svr_free(wr_svr_t* server) {
|
165
164
|
LOG_FUNCTION
|
166
|
-
int i;
|
167
165
|
//Destroy ebb server object
|
168
166
|
ebb_server_unlisten(&(server->ebb_svr));
|
169
167
|
|
data/src/head/wr_worker.c
CHANGED
@@ -308,7 +308,6 @@ static void wr_req_body_write_cb(struct ev_loop *loop, struct ev_io *w, int reve
|
|
308
308
|
//whenever there is a pending request for processing and worker's fd is ready for write, it will dump serialized data to worker by this function
|
309
309
|
static void wr_req_hearer_write_cb(struct ev_loop *loop, struct ev_io *w, int revents) {
|
310
310
|
LOG_FUNCTION
|
311
|
-
int error_flag=0;
|
312
311
|
wr_req_t* req = (wr_req_t*) w->data;
|
313
312
|
wr_wkr_t *worker = req->wkr;
|
314
313
|
LOG_DEBUG(DEBUG,"Request %d",req->id);
|
@@ -500,7 +499,6 @@ void wr_wkr_free(wr_wkr_t *worker) {
|
|
500
499
|
int wr_wkr_remove(wr_wkr_t *worker, int flag) {
|
501
500
|
LOG_FUNCTION
|
502
501
|
wr_app_t* app = worker->app;
|
503
|
-
int i, index;
|
504
502
|
|
505
503
|
if(worker->state & WR_WKR_ACTIVE)
|
506
504
|
worker->state -= WR_WKR_ACTIVE;
|
@@ -537,7 +535,6 @@ int wr_wkr_create(wr_svr_t *server, wr_app_conf_t *app_conf) {
|
|
537
535
|
char cuid_s[WR_SHORT_STR_LEN],
|
538
536
|
cgid_s[WR_SHORT_STR_LEN],
|
539
537
|
controller_path[WR_LONG_STR_LEN],
|
540
|
-
analytics [WR_SHORT_STR_LEN],
|
541
538
|
log_level[WR_SHORT_STR_LEN];
|
542
539
|
|
543
540
|
wr_str_t baseuri;
|
@@ -648,7 +645,6 @@ void wr_wkr_dispatch_req(wr_req_t* req) {
|
|
648
645
|
/** Handle connect request from Worker */
|
649
646
|
int wr_wkr_connect(wr_ctl_t *ctl, const wr_ctl_msg_t *ctl_msg) {
|
650
647
|
LOG_FUNCTION
|
651
|
-
int retval;
|
652
648
|
wr_svr_t* server = ctl->svr;
|
653
649
|
wr_wkr_t* worker = NULL;
|
654
650
|
|
data/src/helper/wr_logger.c
CHANGED
@@ -29,7 +29,6 @@
|
|
29
29
|
#include<errno.h>
|
30
30
|
|
31
31
|
static inline char* get_date_time();
|
32
|
-
static inline char* get_executable_path();
|
33
32
|
static inline char* get_log_file_path();
|
34
33
|
|
35
34
|
//this macro should included in common utility
|
@@ -76,10 +75,7 @@ void redirect_standard_io() {
|
|
76
75
|
}
|
77
76
|
|
78
77
|
/** Initialize logger */
|
79
|
-
int initialize_logger(const char*file_name) {
|
80
|
-
char *path=NULL;
|
81
|
-
|
82
|
-
int retval;
|
78
|
+
int initialize_logger(const char*file_name, const char *server, const char *version) {
|
83
79
|
const char *PATH_SEPARATOR = "/";//in windows we'll need forward slash
|
84
80
|
log_file_path=(char*)malloc(sizeof(char)*512);
|
85
81
|
null_check(log_file_path);
|
@@ -105,7 +101,7 @@ int initialize_logger(const char*file_name) {
|
|
105
101
|
}
|
106
102
|
}
|
107
103
|
|
108
|
-
fprintf(log_fp,"\
|
104
|
+
fprintf(log_fp,"\n%s-%s: Log file opened at %s",server, version, get_date_time());
|
109
105
|
fclose(log_fp);
|
110
106
|
return 0;
|
111
107
|
}
|
@@ -145,7 +141,7 @@ char* get_log_level_string(LOG_SEVERITY level){
|
|
145
141
|
case WARN: return "WARN";
|
146
142
|
case SEVERE: return "SEVERE";
|
147
143
|
case FATAL: return "FATAL";
|
148
|
-
default: "Unknown";
|
144
|
+
default: return "Unknown";
|
149
145
|
}
|
150
146
|
}
|
151
147
|
|
@@ -166,6 +162,7 @@ LOG_SEVERITY get_log_severity(const char*str) {
|
|
166
162
|
if(strcmp(str,"FATAL") == 0) {
|
167
163
|
return FATAL;
|
168
164
|
}
|
165
|
+
return DEBUG;
|
169
166
|
}
|
170
167
|
|
171
168
|
/** Change log file group-owner to given group and user id */
|
@@ -174,7 +171,7 @@ int change_log_file_owner(int user_id, int group_id) {
|
|
174
171
|
}
|
175
172
|
|
176
173
|
/** Set logging level */
|
177
|
-
|
174
|
+
void set_log_severity(int severity) {
|
178
175
|
LOG_INFO("setting log level to %s", get_log_level_string(severity));
|
179
176
|
logging_level = severity;
|
180
177
|
}
|
data/src/helper/wr_logger.h
CHANGED
@@ -65,11 +65,11 @@ typedef enum
|
|
65
65
|
#define LOG_FUNCTION LOG_DEBUG(DEBUG,"%s()", __FUNCTION__);
|
66
66
|
|
67
67
|
void close_logger();
|
68
|
-
int initialize_logger(const char*file_name); //prerequisite to use logger
|
68
|
+
int initialize_logger(const char*file_name, const char *server, const char *version); //prerequisite to use logger
|
69
69
|
void a_log(const char* type,LOG_SEVERITY level,const char* format,...);
|
70
70
|
void a_error(LOG_SEVERITY level, const char *file_name, int line_no, const char *function_name, const char *format, ...);
|
71
71
|
int change_log_file_owner(int user_id, int group_id);
|
72
72
|
LOG_SEVERITY get_log_severity(const char*str);
|
73
|
-
|
73
|
+
void set_log_severity(int);
|
74
74
|
void redirect_standard_io();
|
75
75
|
#endif //end of wr_logger.h
|
data/src/helper/wr_yaml_parser.c
CHANGED
@@ -147,7 +147,7 @@ node_t* yaml_parse(const char*file_name) {
|
|
147
147
|
yaml_event_t event;
|
148
148
|
node_t *node, *config = NULL, *prev;
|
149
149
|
int done = 0, is_key = 0, seq_count = -1, is_seq = 0;
|
150
|
-
char
|
150
|
+
char seq[10][100];
|
151
151
|
node_t* stack[100];
|
152
152
|
int head = -1;
|
153
153
|
|
@@ -62,8 +62,15 @@ module Webroar
|
|
62
62
|
false
|
63
63
|
end
|
64
64
|
|
65
|
-
def write_body(body)
|
66
|
-
if body.
|
65
|
+
def write_body(body)
|
66
|
+
if body.respond_to?(:to_path) and File.exists?(body.to_path)
|
67
|
+
#TODO: Implement 'sendfile' call for kernel-to-kernel transfer.
|
68
|
+
file = File.open(body.to_path, 'rb')
|
69
|
+
while content = file.read(Webroar::READ_CHUNK_SIZE)
|
70
|
+
Webroar::client_write_body(self, content)
|
71
|
+
end
|
72
|
+
file.close
|
73
|
+
elsif body.kind_of?(String)
|
67
74
|
Webroar::client_write_body(self, body)
|
68
75
|
else
|
69
76
|
body.each {|p|
|