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.
Files changed (97) hide show
  1. data/CHANGELOG +48 -1
  2. data/README +11 -14
  3. data/Rakefile +1 -1
  4. data/conf/mime_type.yml +172 -166
  5. data/conf/server_internal_config.yml +30 -8
  6. data/doc/user-guide.html +294 -153
  7. data/doc/user-guide.txt +9 -13
  8. data/lib/command_runner.rb +1 -0
  9. data/lib/dependencies.rb +18 -15
  10. data/lib/installer.rb +115 -50
  11. data/src/admin_panel/app/controllers/admin_controller.rb +1 -15
  12. data/src/admin_panel/app/controllers/application_controller.rb +2 -2
  13. data/src/admin_panel/app/controllers/application_specification_controller.rb +2 -1
  14. data/src/admin_panel/app/controllers/headers_controller.rb +73 -0
  15. data/src/admin_panel/app/controllers/mail_specification_controller.rb +10 -0
  16. data/src/admin_panel/app/controllers/server_specification_controller.rb +14 -0
  17. data/src/admin_panel/app/helpers/admin_helper.rb +0 -85
  18. data/src/admin_panel/app/models/app.rb +1 -1
  19. data/src/admin_panel/app/models/application_specification.rb +33 -25
  20. data/src/admin_panel/app/models/headers.rb +116 -0
  21. data/src/admin_panel/app/models/mail_specification.rb +20 -5
  22. data/src/admin_panel/app/models/server_specification.rb +2 -7
  23. data/src/admin_panel/app/views/admin/configuration.html.erb +10 -5
  24. data/src/admin_panel/app/views/exceptions/_exception_list_partial.html.erb +4 -4
  25. data/src/admin_panel/app/views/graph/_graph_page.html.erb +3 -0
  26. data/src/admin_panel/app/views/headers/_add_expires_text_box.html.erb +35 -0
  27. data/src/admin_panel/app/views/headers/_expires_by_type_form.html.erb +65 -0
  28. data/src/admin_panel/app/views/headers/_headers_table.html.erb +113 -0
  29. data/src/admin_panel/app/views/mail_specification/_current_spec.html.erb +168 -0
  30. data/src/admin_panel/app/views/{admin → server_specification}/_add_div.html.erb +1 -1
  31. data/src/admin_panel/config/initializers/application_constants.rb +6 -0
  32. data/src/admin_panel/lib/control.rb +6 -3
  33. data/src/admin_panel/lib/scgi.rb +74 -21
  34. data/src/admin_panel/lib/yaml_writer.rb +51 -17
  35. data/src/admin_panel/public/javascripts/application.js +20 -1
  36. data/src/head/wr_access_log.c +2 -2
  37. data/src/head/wr_application.c +294 -236
  38. data/src/head/wr_application.h +8 -8
  39. data/src/head/wr_configurator.c +451 -517
  40. data/src/head/wr_configurator.h +10 -115
  41. data/src/head/wr_connection.c +26 -25
  42. data/src/head/wr_connection.h +2 -3
  43. data/src/head/wr_controller.c +110 -93
  44. data/src/head/wr_controller.h +6 -6
  45. data/src/head/wr_main.c +31 -24
  46. data/src/head/wr_request.c +70 -93
  47. data/src/head/wr_request.h +0 -4
  48. data/src/head/wr_resolver.c +21 -15
  49. data/src/head/wr_resolver.h +2 -2
  50. data/src/head/wr_server.c +36 -26
  51. data/src/head/wr_server.h +5 -5
  52. data/src/head/wr_worker.c +551 -512
  53. data/src/head/wr_worker.h +33 -20
  54. data/src/helper/wr_config.c +316 -0
  55. data/src/helper/wr_config.h +235 -0
  56. data/src/helper/wr_helper.h +1 -5
  57. data/src/helper/wr_logger.c +4 -4
  58. data/src/helper/wr_scgi.c +3 -4
  59. data/src/helper/wr_scgi.h +2 -0
  60. data/src/helper/wr_string.h +2 -2
  61. data/src/helper/wr_util.c +3 -1
  62. data/src/helper/wr_util.h +0 -0
  63. data/src/helper/wr_yaml_parser.c +30 -0
  64. data/src/helper/wr_yaml_parser.h +1 -0
  65. data/src/ruby_lib/exception_tracker/instrumentation/action_controller.rb +2 -1
  66. data/src/ruby_lib/mailer/smtpmail.rb +7 -4
  67. data/src/ruby_lib/profiler/instrumentation/action_controller.rb +2 -1
  68. data/src/ruby_lib/profiler/instrumentation/active_record.rb +3 -0
  69. data/src/ruby_lib/rack/adapter/rails.rb +14 -7
  70. data/src/ruby_lib/ruby_interface/client.rb +1 -1
  71. data/src/ruby_lib/ruby_interface/version.rb +2 -2
  72. data/src/ruby_lib/webroar_app_loader.rb +4 -2
  73. data/src/worker/wkr_controller.c +200 -140
  74. data/src/worker/wkr_http.c +14 -28
  75. data/src/worker/wkr_http.h +4 -4
  76. data/src/worker/wkr_http_request.c +12 -11
  77. data/src/worker/wkr_http_request.h +7 -8
  78. data/src/worker/wkr_http_response.c +10 -14
  79. data/src/worker/wkr_http_response.h +0 -1
  80. data/src/worker/wkr_main.c +74 -140
  81. data/src/worker/wkr_static.c +295 -108
  82. data/src/worker/wkr_static.h +20 -7
  83. data/src/worker/worker.c +245 -70
  84. data/src/worker/worker.h +46 -34
  85. data/tasks/compile.rake +128 -175
  86. data/tasks/test.rake +345 -469
  87. data/test/spec/webroar_command_spec.rb +23 -0
  88. metadata +173 -43
  89. data/src/admin_panel/vendor/plugins/action_mailer_optional_tls/README +0 -34
  90. data/src/admin_panel/vendor/plugins/action_mailer_optional_tls/Rakefile +0 -13
  91. data/src/admin_panel/vendor/plugins/action_mailer_optional_tls/init.rb +0 -5
  92. data/src/admin_panel/vendor/plugins/action_mailer_optional_tls/lib/action_mailer_tls.rb +0 -16
  93. data/src/admin_panel/vendor/plugins/action_mailer_optional_tls/lib/smtp_tls.rb +0 -123
  94. data/src/admin_panel/vendor/plugins/action_mailer_optional_tls/test/tls_test.rb +0 -42
  95. data/src/head/wr_config.h +0 -165
  96. data/src/ruby_lib/mailer/action_mailer_tls.rb +0 -16
  97. data/src/ruby_lib/mailer/smtp_tls.rb +0 -123
@@ -21,129 +21,24 @@
21
21
 
22
22
  #include<wr_helper.h>
23
23
 
24
- /** Configuration parameter macros */
25
- #define WR_CONF_SVR_PORT "Server Specification/port"
26
- #define WR_CONF_SVR_MAX_WKR "Server Specification/max_worker"
27
- #define WR_CONF_SVR_MIN_WKR "Server Specification/min_worker"
28
- #define WR_CONF_SVR_LOG_LEVEL "Server Specification/log_level"
29
- #define WR_CONF_SVR_ACCESS_LOG "Server Specification/access_log"
30
-
31
- #define WR_CONF_SVR_SSL_SUPPORT "Server Specification/SSL Specification/ssl_support"
32
-
33
- #ifdef HAVE_GNUTLS
34
- #define WR_CONF_SVR_SSL_CERTIFICATE "Server Specification/SSL Specification/certificate_file"
35
- #define WR_CONF_SVR_SSL_KEY "Server Specification/SSL Specification/key_file"
36
- #define WR_CONF_SVR_SSL_PORT "Server Specification/SSL Specification/ssl_port"
37
- #endif
38
-
39
- #define WR_CONF_APP_SPEC "Application Specification"
40
- #define WR_CONF_APP_NAME "name"
41
- #define WR_CONF_APP_BASE_URI "baseuri"
42
- #define WR_CONF_APP_PATH "path"
43
- #define WR_CONF_APP_TYPE "type"
44
- #define WR_CONF_APP_ANALYTICS "analytics"
45
- #define WR_CONF_APP_USER "run_as_user"
46
- #define WR_CONF_APP_ENV "environment"
47
- #define WR_CONF_APP_LOG_LEVEL "log_level"
48
- #define WR_CONF_APP_MAX_WKR "max_worker"
49
- #define WR_CONF_APP_MIN_WKR "min_worker"
50
- #define WR_CONF_APP_HOST_NAMES "host_names"
51
-
52
- #define WR_CONF_MAX_LEN_APP_NAME 30
53
- #define WR_CONF_MAX_LEN_USR_NAME 30
54
-
55
- // using 'AF_UNIX' macro to identify UDS support.
56
- //#define WR_CONF_UDS 1
57
-
58
- typedef enum wr_host_type_e{
59
- WR_HOST_TPE_INVALID = 0,
60
- WR_HOST_TYPE_STATIC = 1,
61
- WR_HOST_TYPE_WILDCARD_IN_START = 2,
62
- WR_HOST_TYPE_WILDCARD_IN_END = 4,
63
- WR_HOST_TYPE_WILDCARD_IN_START_END = 8,
64
- }wr_host_type_t;
65
-
66
- typedef struct wr_host_name_s wr_host_name_t;
67
- struct wr_host_name_s {
68
- wr_str_t name;
69
- wr_host_type_t type;
70
- wr_host_name_t *next;
71
- };
72
-
73
- #define WR_SVR_ACCESS_LOG 1
74
- #define WR_SVR_SSL_SUPPORT 2
75
-
76
-
77
- /** server_configuration structure */
78
- typedef struct {
79
- wr_u_int port; /**< Server port*/
80
- wr_u_short min_worker; /**< Default number of minimum workers */
81
- wr_u_short max_worker; /**< Default number of maximum workers */
82
- LOG_SEVERITY log_level; /**< Logging level */
83
- //If WR_CONF_UDS is 1 'contol_sock_path' has UDS sock path
84
- //If WR_CONF_UDS is 0 'port' has Internet socket port
85
- wr_u_short ctl_port; /**< Server control port*/
86
- wr_str_t sock_path; /**< Server control socket path in case of UNIX domain socket*/
87
- #ifdef HAVE_GNUTLS
88
-
89
- wr_str_t certificate; /**< Certificate path */
90
- wr_str_t key; /**< Key path */
91
- wr_u_short ssl_port; /**< SSL listening port */
92
- #endif
93
-
94
- short flag;
95
- }wr_svr_conf_t;
96
-
97
- /** application_configuration structure */
98
- typedef struct wr_app_conf_s wr_app_conf_t;
99
- struct wr_app_conf_s {
100
- wr_str_t name; /**< Application name */
101
- wr_str_t path; /**< Application path */
102
- wr_str_t env; /**< Application environment */
103
- wr_str_t type; /**< Application type {rails, merb etc.}*/
104
- short analytics; /**< analytics flag {enabled/disabled} */
105
- wr_str_t baseuri; /**< Application baseuri */
106
- wr_u_short min_worker; /**< Minimum number of workers required */
107
- wr_u_short max_worker; /**< Maximum number of workers */
108
- LOG_SEVERITY log_level; /**< Logging level */
109
- short cuid; /**< User id */
110
- short cgid; /**< Group id */
111
- wr_host_name_t *host_name_list;
112
- wr_app_conf_t *next;
113
- };
114
-
115
- typedef struct wr_conf_s wr_conf_t;
116
24
  /** Remove application_configuration from configuration */
117
- int wr_app_conf_remove(wr_conf_t*, const char *app_name);
25
+ int wr_app_conf_remove(const char *app_name);
118
26
  /** Read application configuration of specified application name */
119
- wr_app_conf_t* wr_conf_app_read(wr_conf_t*, const char *app_name, char* err_msg);
120
- /** Read and update specified application */
121
- wr_app_conf_t* wr_conf_app_update(wr_conf_t* conf, const char *app_name, char* err_msg);
122
- /** Replace the application configuration */
123
- int wr_conf_app_replace(wr_conf_t *conf, wr_app_conf_t *app_conf);
27
+ config_application_list_t* wr_conf_app_read(const char *app_name, char* err_msg, int flag);
28
+ /** Update application configuration with new parameters */
29
+ int wr_conf_app_update(config_application_list_t *app);
124
30
  /** Destroy application configuration */
125
- void wr_conf_app_free(wr_app_conf_t* app);
31
+ void wr_conf_app_free(config_application_list_t* app);
126
32
 
127
- /** configuration structure */
128
- struct wr_conf_s {
129
- wr_svr_conf_t *server; /**< Server configuration */
130
- wr_app_conf_t *apps; /**< Application configuration */
131
- wr_str_t wr_root_path; /**< WebROaR root path */
132
- wr_str_t wkr_exe_path; /**< worker's executable path*/
133
- wr_str_t ruby_lib_path; /**< Ruby library path */
134
- wr_str_t config_file_path; /**< Configuration file path */
135
- wr_str_t admin_panel_path; /**< Admin Panel path */
136
- short uds; /**< UNIX domain socket flag(controlling flag) */
137
- };
138
33
 
139
34
  /** Read 'config.yml' file and fill configuration data structure */
140
- wr_conf_t* wr_conf_read(const char* root_path);
35
+ int wr_conf_read();
141
36
  /** Destroy configuration data structure */
142
- void wr_conf_free(wr_conf_t*);
37
+ void wr_conf_free();
143
38
  /** Display configuration data structure */
144
- void wr_conf_display(wr_conf_t*);
39
+ void wr_conf_display();
145
40
  /** Add Admin Panel to configuration data structure */
146
- int wr_conf_admin_panel_add(wr_conf_t*);
41
+ int wr_conf_admin_panel_add();
147
42
  /** Add the configuration for static content server */
148
- int wr_conf_static_server_add(wr_conf_t*);
43
+ int wr_conf_static_server_add();
149
44
  #endif /*WR_CONFIGURATOR_H_*/
@@ -17,7 +17,8 @@
17
17
  * along with WebROaR. If not, see <http://www.gnu.org/licenses/>.
18
18
  */
19
19
  #include <wr_request.h>
20
- #include <wr_access_log.h>
20
+
21
+ extern config_t *Config;
21
22
 
22
23
  // Connection count
23
24
  static unsigned int wr_conn_count = 0;
@@ -39,7 +40,8 @@ static wr_http_status_t http_status [] ={
39
40
  {413, "413 Request Entity Too Large", "The request entity is too large"},
40
41
  {414, "414 Request-URI Too Large", "The request URI is too large"},
41
42
  {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
+ {501, "501 Not Implemented", "The server does not support the functionality required to fulfill the request."},
44
+ {503, "503 Service Unavailable", "The server is currently unable to handle the request due to a temporary overloading or maintenance of the server."}
43
45
  };
44
46
 
45
47
  #define WR_RESP_BODY "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n\
@@ -92,7 +94,7 @@ void wr_conn_after_write_cb(ebb_connection *connection) {
92
94
  wr_conn_after_write_cb);
93
95
  } else if(conn->resp_to_write <= 0) {
94
96
  LOG_DEBUG(DEBUG,"response to write is less than 1 keep alive =%d", conn->keep_alive);
95
- if(!WR_SVR_KEEP_ALIVE || !conn->keep_alive) {
97
+ if(!(SERVER_KEEP_ALIVE & Config->Server.flag) || !conn->keep_alive) {
96
98
  // Close ebb_connection if there is no any pending request
97
99
  LOG_DEBUG(DEBUG,"Closing Connection %d ...", conn->id);
98
100
  ebb_connection_schedule_close(connection);
@@ -108,9 +110,6 @@ void wr_req_parse_err_cb(ebb_connection* connection) {
108
110
  LOG_DEBUG(DEBUG,"Connection id = %d",conn->id);
109
111
  conn->keep_alive = 0;
110
112
  wr_req_invalid(conn, WR_HTTP_STATUS_400);
111
- // if(conn->resp_to_write == 0)
112
- // conn->resp_to_write = 1;
113
- // wr_server_err_response(conn, WR_HTTP_STATUS_400);
114
113
  }
115
114
 
116
115
  /** The ebb connection goes timeout */
@@ -147,29 +146,25 @@ void wr_conn_close_cb(ebb_connection* connection) {
147
146
  }
148
147
  }
149
148
 
150
- /********************************************************
151
- * Connection Function Definition *
152
- ********************************************************/
153
-
154
149
  /** Create new Connection */
155
150
  wr_conn_t* wr_conn_new(wr_svr_t *server) {
156
151
  LOG_FUNCTION
157
152
  wr_conn_t* a_connection = wr_malloc(wr_conn_t);
158
-
153
+
159
154
  if(a_connection == NULL) {
160
155
  LOG_DEBUG(SEVERE, "Error a_connection is null. Returning ...");
161
156
  return NULL;
162
157
  }
163
158
  ebb_connection *connection = wr_malloc(ebb_connection);
164
-
159
+
165
160
  if(connection == NULL) {
166
161
  free(a_connection);
167
162
  LOG_DEBUG(SEVERE, "Error connection is null. Returning ...");
168
163
  return NULL;
169
164
  }
170
-
165
+
171
166
  ebb_connection_init(connection);
172
-
167
+
173
168
  a_connection->id = ++wr_conn_count;
174
169
  a_connection->resp_to_write = 0;
175
170
  a_connection->ebb_conn = connection;
@@ -184,10 +179,15 @@ wr_conn_t* wr_conn_new(wr_svr_t *server) {
184
179
  connection->on_close = wr_conn_close_cb;
185
180
  connection->on_timeout = wr_conn_timeout_cb;
186
181
  connection->on_request_parse_error = wr_req_parse_err_cb;
187
-
182
+
188
183
  return a_connection;
189
184
  }
190
185
 
186
+
187
+ /********************************************************
188
+ * Connection Function Definition *
189
+ ********************************************************/
190
+
191
191
  /** Destroy Connection */
192
192
  void wr_conn_free(wr_conn_t *conn) {
193
193
  LOG_FUNCTION
@@ -251,22 +251,22 @@ ebb_connection* wr_new_conn_cb(ebb_server* server, struct sockaddr_in* addr) {
251
251
  /** Response generated by Server */
252
252
  void wr_conn_err_resp(wr_conn_t *conn, wr_resp_status_t resp_code) {
253
253
  LOG_FUNCTION
254
- char response_body[WR_LONG_LONG_STR_LEN];
255
- char response_buff[WR_LONG_LONG_STR_LEN*2];
254
+ char response_body[STR_SIZE512];
255
+ char response_buff[STR_SIZE512*2];
256
256
  size_t body_len, buff_len;
257
257
 
258
258
  LOG_DEBUG(DEBUG, "response code = %s",http_status[resp_code].phrase);
259
259
  conn->keep_alive = 0;
260
260
 
261
- char current_date[WR_STR_LEN];
262
- get_time(current_date, WR_STR_LEN);
261
+ char current_date[STR_SIZE64];
262
+ get_time(current_date, STR_SIZE64);
263
263
 
264
264
  switch(resp_code) {
265
265
  case WR_HTTP_STATUS_100:
266
266
  body_len = 0;
267
267
  buff_len = sprintf(response_buff, WR_RESP_HEADERS,
268
- http_status[resp_code].phrase, current_date, WR_SERVER,
269
- WR_VERSION, body_len, http_status[resp_code].message);
268
+ http_status[resp_code].phrase, current_date, Config->Server.name.str,
269
+ Config->Server.version.str, body_len, http_status[resp_code].message);
270
270
  break;
271
271
  case WR_HTTP_STATUS_400:
272
272
  case WR_HTTP_STATUS_403:
@@ -277,21 +277,22 @@ void wr_conn_err_resp(wr_conn_t *conn, wr_resp_status_t resp_code) {
277
277
  case WR_HTTP_STATUS_414:
278
278
  case WR_HTTP_STATUS_500:
279
279
  case WR_HTTP_STATUS_501:
280
+ case WR_HTTP_STATUS_503:
280
281
  if(conn->req && conn->req->resp_buf_len > 0) {
281
282
  body_len = sprintf(response_body, WR_RESPONSE_ERR_BODY,
282
283
  http_status[resp_code].phrase,http_status[resp_code].phrase+4,
283
284
  http_status[resp_code].message,
284
285
  conn->req->resp_buf,
285
- WR_SERVER, WR_VERSION);
286
+ Config->Server.name.str, Config->Server.version.str);
286
287
  } else {
287
288
  body_len = sprintf(response_body, WR_RESP_BODY,
288
289
  http_status[resp_code].phrase,http_status[resp_code].phrase+4,
289
- http_status[resp_code].message,WR_SERVER, WR_VERSION);
290
+ http_status[resp_code].message,Config->Server.name.str, Config->Server.version.str);
290
291
  }
291
292
 
292
293
  buff_len = sprintf(response_buff, WR_RESP_HEADERS,
293
294
  http_status[resp_code].phrase, current_date,
294
- WR_SERVER, WR_VERSION, body_len, response_body);
295
+ Config->Server.name.str, Config->Server.version.str, body_len, response_body);
295
296
  break;
296
297
  }
297
298
 
@@ -299,7 +300,7 @@ void wr_conn_err_resp(wr_conn_t *conn, wr_resp_status_t resp_code) {
299
300
 
300
301
  if(conn->req) {
301
302
  wr_req_t* req = conn->req;
302
- if(conn->svr->conf->server->flag&WR_SVR_ACCESS_LOG) {
303
+ if(Config->Server.flag & SERVER_ACCESS_LOG) {
303
304
  req->resp_body_len = body_len;
304
305
  req->resp_code = http_status[resp_code].code;
305
306
  wr_access_log(req);
@@ -35,8 +35,6 @@ typedef struct {
35
35
  wr_str_list_t *resp;
36
36
  }wr_conn_t;
37
37
 
38
- /** Create new Connection */
39
- wr_conn_t* wr_conn_new(wr_svr_t*);
40
38
  /** Destroy Connection */
41
39
  void wr_conn_free(wr_conn_t*);
42
40
  /** Add response to Connection */
@@ -59,7 +57,8 @@ typedef enum {
59
57
  WR_HTTP_STATUS_413 ,
60
58
  WR_HTTP_STATUS_414 ,
61
59
  WR_HTTP_STATUS_500 ,
62
- WR_HTTP_STATUS_501
60
+ WR_HTTP_STATUS_501 ,
61
+ WR_HTTP_STATUS_503
63
62
  }wr_resp_status_t;
64
63
 
65
64
  /** Response generated by Server */