webroar 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- 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/head/wr_configurator.c
CHANGED
@@ -20,296 +20,197 @@
|
|
20
20
|
* Implementation of CONFIGURATOR module
|
21
21
|
*****************************************************************************/
|
22
22
|
|
23
|
-
#include <
|
24
|
-
#include <wr_config.h>
|
23
|
+
#include <wr_request.h>
|
25
24
|
#include <sys/stat.h>
|
26
25
|
#include <sys/socket.h>
|
27
26
|
#include <pwd.h>
|
28
27
|
|
28
|
+
extern config_t *Config;
|
29
|
+
|
30
|
+
#define WR_CONF_MAX_LEN_APP_NAME 30
|
31
|
+
#define WR_CONF_MAX_LEN_USR_NAME 30
|
32
|
+
|
29
33
|
/*********************************************************
|
30
34
|
* Private function definitions
|
31
35
|
**********************************************************/
|
32
36
|
|
33
|
-
static void wr_host_name_free(wr_host_name_t *host) {
|
34
|
-
LOG_FUNCTION
|
35
|
-
wr_host_name_t *next;
|
36
|
-
while(host) {
|
37
|
-
next = host->next;
|
38
|
-
wr_string_free(host->name);
|
39
|
-
free(host);
|
40
|
-
host = next;
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
/** Destroy application configuration */
|
45
|
-
void wr_conf_app_free(wr_app_conf_t* app) {
|
46
|
-
LOG_FUNCTION
|
47
|
-
wr_app_conf_t* next;
|
48
|
-
|
49
|
-
// Iterate applications and destroy each application
|
50
|
-
while(app) {
|
51
|
-
next = app->next;
|
52
|
-
wr_string_free(app->name);
|
53
|
-
wr_string_free(app->path);
|
54
|
-
wr_string_free(app->env);
|
55
|
-
wr_string_free(app->type);
|
56
|
-
wr_string_free(app->baseuri);
|
57
|
-
wr_host_name_free(app->host_name_list);
|
58
|
-
free(app);
|
59
|
-
app = next;
|
60
|
-
}
|
61
|
-
}
|
62
|
-
|
63
37
|
/** Create new application configuration with default values inherited from server configuration */
|
64
|
-
|
38
|
+
config_application_list_t* wr_config_application_new(){
|
65
39
|
LOG_FUNCTION
|
66
|
-
|
67
|
-
app->log_level =
|
68
|
-
app->min_worker =
|
69
|
-
app->max_worker =
|
70
|
-
app->cgid = -1;
|
71
|
-
app->cuid = -1;
|
40
|
+
config_application_list_t* app = wr_malloc(config_application_list_t);
|
41
|
+
app->log_level = Config->Server.log_level;
|
42
|
+
app->min_worker = Config->Application.Default.min_workers;
|
43
|
+
app->max_worker = Config->Application.Default.max_workers;
|
72
44
|
wr_string_null(app->name);
|
73
|
-
wr_string_null(app->path);
|
74
45
|
wr_string_null(app->baseuri);
|
75
|
-
wr_string_null(app->
|
76
|
-
|
77
|
-
app->analytics = FALSE;
|
46
|
+
wr_string_null(app->path);
|
47
|
+
app->scgi = NULL;
|
78
48
|
app->host_name_list = NULL;
|
49
|
+
app->new = NULL;
|
79
50
|
app->next = NULL;
|
80
51
|
return app;
|
81
52
|
}
|
82
53
|
|
83
|
-
/**
|
84
|
-
|
54
|
+
/** Set SCGI Config request */
|
55
|
+
int wr_app_conf_req_set(config_application_list_t *app, node_t *app_node){
|
85
56
|
LOG_FUNCTION
|
86
|
-
|
57
|
+
char *str;
|
58
|
+
|
59
|
+
app->scgi = scgi_new();
|
87
60
|
|
88
|
-
|
89
|
-
|
90
|
-
return NULL;
|
61
|
+
if(!app->scgi) {
|
62
|
+
return FALSE;
|
91
63
|
}
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
conf->server->min_worker = WR_MIN_WKR;
|
110
|
-
conf->server->max_worker = WR_MAX_WKR;
|
111
|
-
conf->server->log_level = SEVERE;
|
112
|
-
conf->server->flag = 0;
|
113
|
-
conf->server->ctl_port = 0;
|
114
|
-
wr_string_null(conf->server->sock_path);
|
115
|
-
#ifdef HAVE_GNUTLS
|
116
|
-
|
117
|
-
wr_string_null(conf->server->certificate);
|
118
|
-
wr_string_null(conf->server->key);
|
119
|
-
conf->server->ssl_port = WR_DEFAULT_SSL_PORT;
|
120
|
-
#endif
|
121
|
-
|
122
|
-
wr_string_null(conf->wr_root_path);
|
123
|
-
wr_string_null(conf->wkr_exe_path);
|
124
|
-
wr_string_null(conf->admin_panel_path);
|
125
|
-
wr_string_null(conf->ruby_lib_path);
|
126
|
-
wr_string_null(conf->config_file_path);
|
127
|
-
|
128
|
-
conf->apps = NULL;
|
129
|
-
|
130
|
-
return conf;
|
131
|
-
}
|
132
|
-
|
133
|
-
/** Initialize configuration path variables */
|
134
|
-
static inline void wr_init_path(wr_conf_t *conf, const char *root_path) {
|
135
|
-
|
136
|
-
LOG_FUNCTION
|
137
|
-
size_t len;
|
138
|
-
char str[WR_LONG_LONG_STR_LEN];
|
139
|
-
|
140
|
-
// set WebROaR root fodler path
|
141
|
-
len = strlen(root_path);
|
142
|
-
wr_string_new(conf->wr_root_path, root_path, len);
|
143
|
-
|
144
|
-
// Set configuration file path
|
145
|
-
len = sprintf(str,"%s%sconf%s%s",
|
146
|
-
root_path, WR_PATH_SEPARATOR,
|
147
|
-
WR_PATH_SEPARATOR,WR_CONF_FILE);
|
148
|
-
wr_string_new(conf->config_file_path, str, len);
|
149
|
-
|
150
|
-
// Set the 'webroar-worker' file path
|
151
|
-
len = sprintf(str,"%s%s%s%s%s",root_path, WR_PATH_SEPARATOR,
|
152
|
-
WR_BIN_DIR, WR_PATH_SEPARATOR,
|
153
|
-
WR_WKR_BIN);
|
154
|
-
wr_string_new(conf->wkr_exe_path, str, len);
|
155
|
-
|
156
|
-
// Set ruby lib folder path
|
157
|
-
len = sprintf(str,"%s%s%s%s%s",
|
158
|
-
root_path, WR_PATH_SEPARATOR,
|
159
|
-
WR_SRC_DIR, WR_PATH_SEPARATOR,
|
160
|
-
WR_RUBY_LIB_DIR);
|
161
|
-
wr_string_new(conf->ruby_lib_path, str, len);
|
162
|
-
|
163
|
-
// Set Admin Panel folder path
|
164
|
-
len = sprintf(str,"%s%s%s%s%s",
|
165
|
-
root_path, WR_PATH_SEPARATOR,
|
166
|
-
WR_SRC_DIR, WR_PATH_SEPARATOR,
|
167
|
-
WR_ADMIN_PANEL_DIR);
|
168
|
-
wr_string_new(conf->admin_panel_path, str, len);
|
169
|
-
}
|
170
|
-
|
171
|
-
/** Validate YAML tokens */
|
172
|
-
static inline char* wr_validate_string(const char* str) {
|
173
|
-
int count, len, is_blank, is_comment;
|
174
|
-
|
175
|
-
if(str == NULL)
|
176
|
-
return NULL;
|
64
|
+
|
65
|
+
scgi_header_add(app->scgi, "COMPONENT", strlen("COMPONENT"), "WORKER", strlen("WORKER"));
|
66
|
+
scgi_header_add(app->scgi, "METHOD", strlen("METHOD"), "CONF_REQ", strlen("CONF_REQ"));
|
67
|
+
scgi_header_add(app->scgi, "STATUS", strlen("STATUS"), "OK", strlen("OK"));
|
68
|
+
scgi_header_add(app->scgi, "NAME", strlen("NAME"), app->name.str, app->name.len);
|
69
|
+
scgi_header_add(app->scgi, "PATH", strlen("PATH"), app->path.str, app->path.len);
|
70
|
+
if(!wr_string_is_empty(app->baseuri))
|
71
|
+
scgi_header_add(app->scgi, "BASE_URI", strlen("BASE_URI"), app->baseuri.str, app->baseuri.len);
|
72
|
+
|
73
|
+
str = wr_validate_string(get_node_value(app_node->child, "type"));
|
74
|
+
scgi_header_add(app->scgi, "TYPE", strlen("TYPE"), str, strlen(str));
|
75
|
+
|
76
|
+
str = wr_validate_string(get_node_value(app_node->child, "analytics"));
|
77
|
+
scgi_header_add(app->scgi, "ANALYTICS", strlen("ANALYTICS"), str, strlen(str));
|
78
|
+
|
79
|
+
str = wr_validate_string(get_node_value(app_node->child, "run_as_user"));
|
80
|
+
scgi_header_add(app->scgi, "USER", strlen("USER"), str, strlen(str));
|
177
81
|
|
178
|
-
//Set
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
82
|
+
// Set application environment
|
83
|
+
str = wr_validate_string(get_node_value(app_node->child, "environment"));
|
84
|
+
if(str){
|
85
|
+
scgi_header_add(app->scgi, "ENV", strlen("ENV"), str, strlen(str));
|
86
|
+
}else{
|
87
|
+
scgi_header_add(app->scgi, "ENV", strlen("ENV"), Config->Application.Default.env.str, Config->Application.Default.env.len);
|
88
|
+
}
|
89
|
+
|
90
|
+
node_t *nodes = get_nodes(app_node->child, "environment_variables/set_env");
|
91
|
+
wr_str_t val;
|
92
|
+
wr_string_null(val);
|
93
|
+
while(nodes){
|
94
|
+
str = wr_validate_string(NODE_VALUE(nodes));
|
95
|
+
if(str){
|
96
|
+
if(wr_string_is_empty(val)){
|
97
|
+
wr_string_new(val, str, strlen(str));
|
98
|
+
}else{
|
99
|
+
wr_string_append(val, "#", 1);
|
100
|
+
wr_string_append(val, str, strlen(str));
|
101
|
+
}
|
191
102
|
}
|
103
|
+
nodes = NODE_NEXT(nodes);
|
192
104
|
}
|
193
|
-
if(
|
194
|
-
|
195
|
-
return NULL;
|
105
|
+
if(!wr_string_is_empty(val)){
|
106
|
+
scgi_header_add(app->scgi, "ENV_VAR", strlen("ENV_VAR"), val.str, val.len);
|
196
107
|
}
|
197
|
-
|
108
|
+
wr_string_free(val);
|
109
|
+
scgi_build(app->scgi);
|
110
|
+
|
111
|
+
return TRUE;
|
198
112
|
}
|
199
113
|
|
200
114
|
/** Set Server Configuration */
|
201
|
-
|
115
|
+
int wr_config_server_set(node_t *root) {
|
202
116
|
LOG_FUNCTION
|
203
|
-
wr_svr_conf_t *server = conf->server;
|
204
117
|
char *str;
|
205
118
|
|
206
119
|
// Set server listening port
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
if(server->port < 0 || server->port > 65536) {
|
120
|
+
wr_set_numeric_value(root, "Server Specification/port", &Config->Server.port, FALSE);
|
121
|
+
|
122
|
+
if(Config->Server.port < 0 || Config->Server.port > 65536) {
|
212
123
|
LOG_ERROR(SEVERE,"Valid port should be a number between 1 and 65536. Server can not start.");
|
213
124
|
printf("Valid port should be a number between 1 and 65536. Server can not start.\n");
|
214
125
|
return -1;
|
215
126
|
}
|
216
127
|
|
217
128
|
// Set min_worker
|
218
|
-
|
219
|
-
if(
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
printf("Server Specification: Minimum workers should be a number between 1 and %d. Server can not start.\n", WR_ALLOWED_MAX_WORKERS);
|
224
|
-
return -1;
|
225
|
-
}
|
129
|
+
wr_set_numeric_value(root, "Server Specification/min_worker", &Config->Application.Default.min_workers, FALSE);
|
130
|
+
if(Config->Application.Default.min_workers > Config->Server.Worker.max) {
|
131
|
+
LOG_ERROR(SEVERE, "Server Specification: Minimum workers should be a number between 1 and %d. Server can not start.", Config->Server.Worker.max);
|
132
|
+
printf("Server Specification: Minimum workers should be a number between 1 and %d. Server can not start.\n", Config->Server.Worker.max);
|
133
|
+
return -1;
|
226
134
|
}
|
227
135
|
|
136
|
+
|
228
137
|
// Set max_worker
|
229
|
-
|
230
|
-
if(
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
printf("Server Specification: Maximum workers should be a number between 1 and %d. Server can not start.\n", WR_ALLOWED_MAX_WORKERS);
|
235
|
-
return -1;
|
236
|
-
}
|
138
|
+
wr_set_numeric_value(root, "Server Specification/max_worker", &Config->Application.Default.max_workers, FALSE);
|
139
|
+
if(Config->Application.Default.max_workers > Config->Server.Worker.max) {
|
140
|
+
LOG_ERROR(SEVERE, "Server Specification: Maximum workers should be a number between 1 and %d. Server can not start.", Config->Server.Worker.max);
|
141
|
+
printf("Server Specification: Maximum workers should be a number between 1 and %d. Server can not start.\n", Config->Server.Worker.max);
|
142
|
+
return -1;
|
237
143
|
}
|
238
144
|
|
239
|
-
if(
|
145
|
+
if(Config->Application.Default.min_workers > Config->Application.Default.max_workers) {
|
240
146
|
LOG_ERROR(SEVERE,"Server Specification: Min worker value is greater than Max worker value. Server can not start.");
|
241
147
|
printf("Server Specification: Min worker value is greater than Max worker value. Server can not start.\n");
|
242
148
|
return -1;
|
243
149
|
}
|
244
150
|
|
245
151
|
// Set logging level
|
246
|
-
str = wr_validate_string(get_node_value(root,
|
152
|
+
str = wr_validate_string(get_node_value(root, "Server Specification/log_level"));
|
247
153
|
if(str)
|
248
|
-
|
249
|
-
|
154
|
+
Config->Server.log_level = get_log_severity(str);
|
155
|
+
|
250
156
|
// Set access log flag
|
251
|
-
str = wr_validate_string(get_node_value(root,
|
157
|
+
str = wr_validate_string(get_node_value(root, "Server Specification/access_log"));
|
252
158
|
|
253
159
|
if(str && strcmp(str,"enabled")==0 ) {
|
254
|
-
|
160
|
+
Config->Server.flag |= SERVER_ACCESS_LOG;
|
255
161
|
}
|
256
162
|
|
257
163
|
//check ssl support
|
258
|
-
str = wr_validate_string(get_node_value(root,
|
164
|
+
str = wr_validate_string(get_node_value(root, "Server Specification/SSL Specification/ssl_support"));
|
259
165
|
if(str && strcmp(str,"enabled")==0 ) {
|
260
|
-
|
166
|
+
Config->Server.flag |= SERVER_SSL_SUPPORT;
|
261
167
|
}
|
262
168
|
|
263
169
|
#ifdef HAVE_GNUTLS
|
264
170
|
|
265
|
-
if(
|
171
|
+
if(Config->Server.flag & SERVER_SSL_SUPPORT) {
|
266
172
|
size_t len;
|
267
173
|
struct stat buff;
|
268
174
|
// Set certificate path
|
269
|
-
str = wr_validate_string(get_node_value(root,
|
175
|
+
str = wr_validate_string(get_node_value(root, "Server Specification/SSL Specification/certificate_file"));
|
270
176
|
if(str) {
|
271
177
|
if(stat(str,&buff)!=0) {
|
272
178
|
LOG_ERROR(SEVERE,"SSL certificate file path(%s) invalid. Server can not run on SSL.",str);
|
273
179
|
printf("SSL certificate file path(%s) invalid. Server can not run on SSL.\n",str);
|
274
|
-
|
180
|
+
Config->Server.flag &= (!SERVER_SSL_SUPPORT);
|
275
181
|
} else {
|
276
182
|
len = strlen(str);
|
277
|
-
wr_string_new(
|
183
|
+
wr_string_new(Config->Server.SSL.certificate, str, len);
|
278
184
|
}
|
279
185
|
} else {
|
280
186
|
LOG_ERROR(SEVERE,"Certificate file path is missing. Server can not run on SSL.");
|
281
187
|
printf("Certificate file path is missing. Server can not run on SSL.\n");
|
282
|
-
|
188
|
+
Config->Server.flag &= (!SERVER_SSL_SUPPORT);
|
283
189
|
}
|
284
190
|
|
285
191
|
// Set certificate path
|
286
|
-
str = wr_validate_string(get_node_value(root,
|
192
|
+
str = wr_validate_string(get_node_value(root, "Server Specification/SSL Specification/key_file"));
|
287
193
|
if(str) {
|
288
194
|
if(stat(str,&buff)!=0) {
|
289
195
|
LOG_ERROR(SEVERE,"SSL key file path(%s) invalid. Server can not run on SSL.",str);
|
290
196
|
printf("SSL key file path(%s) invalid. Server can not run on SSL.\n",str);
|
291
|
-
|
197
|
+
Config->Server.flag &= (!SERVER_SSL_SUPPORT);
|
292
198
|
} else {
|
293
199
|
len = strlen(str);
|
294
|
-
wr_string_new(
|
200
|
+
wr_string_new(Config->Server.SSL.key, str, len);
|
295
201
|
}
|
296
202
|
} else {
|
297
203
|
LOG_ERROR(SEVERE,"SSL key file path is missing. Server can not run on SSL.");
|
298
204
|
printf("SSL key file path is missing. Server can not run on SSL.\n");
|
299
|
-
|
205
|
+
Config->Server.flag &= (!SERVER_SSL_SUPPORT);
|
300
206
|
}
|
301
207
|
|
302
208
|
// Set server listening port
|
303
|
-
|
304
|
-
if(
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
printf("Given SSL port is invalid. Valid port should be a number between 1 and 65536. Server can not run on SSL.\n");
|
309
|
-
server->flag &= (!WR_SVR_SSL_SUPPORT);
|
310
|
-
}
|
311
|
-
} else {
|
312
|
-
server->ssl_port = WR_DEFAULT_SSL_PORT;
|
209
|
+
wr_set_numeric_value(root, "Server Specification/SSL Specification/ssl_port", &Config->Server.SSL.port, FALSE);
|
210
|
+
if(Config->Server.SSL.port < 0 || Config->Server.SSL.port > 65536) {
|
211
|
+
LOG_ERROR(SEVERE,"Given SSL port is invalid. Valid port should be a number between 1 and 65536. Server can not run on SSL.");
|
212
|
+
printf("Given SSL port is invalid. Valid port should be a number between 1 and 65536. Server can not run on SSL.\n");
|
213
|
+
Config->Server.flag &= (!SERVER_SSL_SUPPORT);
|
313
214
|
}
|
314
215
|
}
|
315
216
|
|
@@ -318,7 +219,7 @@ static inline int wr_conf_server_set(wr_conf_t * conf, node_t *root) {
|
|
318
219
|
return 0;
|
319
220
|
}
|
320
221
|
|
321
|
-
|
222
|
+
int wr_validate_app_host_name(const char *host_name, char *err_msg) {
|
322
223
|
LOG_FUNCTION
|
323
224
|
int down_level = 1, label_len, i;
|
324
225
|
char *label = NULL;
|
@@ -393,10 +294,10 @@ err_ret:
|
|
393
294
|
return -1;
|
394
295
|
}
|
395
296
|
|
396
|
-
|
297
|
+
int wr_app_host_name_set(config_application_list_t *app, char *host_names, char *err_msg) {
|
397
298
|
LOG_FUNCTION
|
398
|
-
char *host = NULL, *host_array[
|
399
|
-
|
299
|
+
char *host = NULL, *host_array[Config->Application.max_hosts];
|
300
|
+
config_host_list_t *hosts = NULL, *tmp_host = NULL;
|
400
301
|
int rv, counter = 0, no_of_hosts = 0;
|
401
302
|
size_t len;
|
402
303
|
|
@@ -407,7 +308,7 @@ static int wr_app_host_name_set(wr_app_conf_t *app, char *host_names, char *err_
|
|
407
308
|
/* Tokenizing all the hostnames here, as in wr_validate_app_host_name() individual hostname is again tokenizing for further validations.
|
408
309
|
* Call to second strtok for tokenizing of new string, before completion of its first call, messing up with the original string of first call. */
|
409
310
|
host = strtok(host_names, " ");
|
410
|
-
while(host && counter <
|
311
|
+
while(host && counter < Config->Application.max_hosts) {
|
411
312
|
host_array[counter++] = host;
|
412
313
|
host = strtok(NULL, " ");
|
413
314
|
}
|
@@ -426,28 +327,28 @@ static int wr_app_host_name_set(wr_app_conf_t *app, char *host_names, char *err_
|
|
426
327
|
return -1;
|
427
328
|
|
428
329
|
len = strlen(host);
|
429
|
-
tmp_host = wr_malloc(
|
330
|
+
tmp_host = wr_malloc(config_host_list_t);
|
430
331
|
if(tmp_host == NULL)
|
431
332
|
return -1;
|
432
333
|
|
433
334
|
tmp_host->next = NULL;
|
434
|
-
tmp_host->type =
|
335
|
+
tmp_host->type = HOST_TPE_INVALID;
|
435
336
|
//storing plain name, removing any '*', and '~'
|
436
337
|
if(host[1] == '*') {
|
437
338
|
if(host[len-1] == '*') {
|
438
|
-
tmp_host->type =
|
339
|
+
tmp_host->type = HOST_TYPE_WILDCARD_IN_START_END;
|
439
340
|
wr_string_new(tmp_host->name, host+2, len-3);
|
440
341
|
} else {
|
441
|
-
tmp_host->type =
|
342
|
+
tmp_host->type = HOST_TYPE_WILDCARD_IN_START;
|
442
343
|
wr_string_new(tmp_host->name, host+2, len-2);
|
443
344
|
}
|
444
345
|
LOG_DEBUG(DEBUG, "Host name = %s", tmp_host->name.str);
|
445
346
|
} else if(host[len-1] == '*') {
|
446
|
-
tmp_host->type =
|
347
|
+
tmp_host->type = HOST_TYPE_WILDCARD_IN_END;
|
447
348
|
wr_string_new(tmp_host->name, host+1, len-2);
|
448
349
|
LOG_DEBUG(DEBUG, "Host name = %s", tmp_host->name.str);
|
449
350
|
} else {
|
450
|
-
tmp_host->type =
|
351
|
+
tmp_host->type = HOST_TYPE_STATIC;
|
451
352
|
if(host[0] == '~') {
|
452
353
|
wr_string_new(tmp_host->name, host+1, len-1);
|
453
354
|
} else {
|
@@ -467,23 +368,23 @@ static int wr_app_host_name_set(wr_app_conf_t *app, char *host_names, char *err_
|
|
467
368
|
}
|
468
369
|
|
469
370
|
/** Create and fill application configuration */
|
470
|
-
|
371
|
+
config_application_list_t* wr_config_application_set(node_t* app_node, char* err_msg) {
|
471
372
|
LOG_FUNCTION
|
472
|
-
|
373
|
+
config_application_list_t *app = NULL;
|
473
374
|
struct stat buff;
|
474
375
|
char *str, *app_name;
|
475
376
|
short free_app_obj = 0;
|
476
377
|
size_t len;
|
477
378
|
|
478
379
|
// Create application configuration with default values
|
479
|
-
app =
|
380
|
+
app = wr_config_application_new();
|
480
381
|
|
481
382
|
if(!app) {
|
482
383
|
return NULL;
|
483
384
|
}
|
484
|
-
|
385
|
+
|
485
386
|
//Set application name
|
486
|
-
str = wr_validate_string(get_node_value(app_node->child,
|
387
|
+
str = wr_validate_string(get_node_value(app_node->child, "name"));
|
487
388
|
len = strlen(str);
|
488
389
|
if(str && len > 0 && len < WR_CONF_MAX_LEN_APP_NAME) {
|
489
390
|
wr_string_new(app->name, str, len);
|
@@ -494,19 +395,19 @@ static inline wr_app_conf_t* wr_app_conf_set (wr_conf_t* conf, node_t* app_node,
|
|
494
395
|
printf("Application name is too long. Maximum is %d characters\n", WR_CONF_MAX_LEN_APP_NAME);
|
495
396
|
if(err_msg)
|
496
397
|
sprintf(err_msg,"\n Application name is too long. Maximum is %d characters", WR_CONF_MAX_LEN_APP_NAME);
|
497
|
-
|
398
|
+
wr_application_list_free(app);
|
498
399
|
return NULL;
|
499
400
|
} else {
|
500
401
|
LOG_ERROR(SEVERE,"Application name is missing");
|
501
402
|
printf("Application name is missing.\n");
|
502
403
|
if(err_msg)
|
503
404
|
sprintf(err_msg+strlen(err_msg),"\nApplication name is missing.");
|
504
|
-
|
405
|
+
wr_application_list_free(app);
|
505
406
|
return NULL;
|
506
407
|
}
|
507
408
|
|
508
409
|
// Set application path
|
509
|
-
str = wr_validate_string(get_node_value(app_node->child,
|
410
|
+
str = wr_validate_string(get_node_value(app_node->child, "path"));
|
510
411
|
if(str && strlen(str) > 0) {
|
511
412
|
//Check existence of application path
|
512
413
|
if(stat(str,&buff)!=0) {
|
@@ -519,7 +420,7 @@ static inline wr_app_conf_t* wr_app_conf_set (wr_conf_t* conf, node_t* app_node,
|
|
519
420
|
}
|
520
421
|
len = strlen(str);
|
521
422
|
wr_string_new(app->path, str, len);
|
522
|
-
LOG_DEBUG(DEBUG, "Application Path = %s",
|
423
|
+
LOG_DEBUG(DEBUG, "Application Path = %s", str);
|
523
424
|
} else {
|
524
425
|
LOG_ERROR(SEVERE,"Application path for %s is missing. Application not started.", app_name);
|
525
426
|
printf("Application path for %s is missing. Application not started\n", app_name);
|
@@ -530,11 +431,9 @@ static inline wr_app_conf_t* wr_app_conf_set (wr_conf_t* conf, node_t* app_node,
|
|
530
431
|
}
|
531
432
|
|
532
433
|
// Set application type
|
533
|
-
str = wr_validate_string(get_node_value(app_node->child,
|
434
|
+
str = wr_validate_string(get_node_value(app_node->child, "type"));
|
534
435
|
if(str && strlen(str) > 0) {
|
535
|
-
|
536
|
-
wr_string_new(app->type, str, len);
|
537
|
-
LOG_DEBUG(DEBUG, "Application Type = %s", app->type.str);
|
436
|
+
LOG_DEBUG(DEBUG, "Application Type = %s", str);
|
538
437
|
} else {
|
539
438
|
LOG_ERROR(SEVERE,"Application type for %s is missing", app_name);
|
540
439
|
printf("Application type for %s is missing\n", app_name);
|
@@ -545,12 +444,10 @@ static inline wr_app_conf_t* wr_app_conf_set (wr_conf_t* conf, node_t* app_node,
|
|
545
444
|
}
|
546
445
|
|
547
446
|
// Set application analytics
|
548
|
-
str = wr_validate_string(get_node_value(app_node->child,
|
447
|
+
str = wr_validate_string(get_node_value(app_node->child, "analytics"));
|
549
448
|
if(str && strlen(str) > 0) {
|
449
|
+
len = strlen(str);
|
550
450
|
LOG_DEBUG(DEBUG,"App analytics = %s", str);
|
551
|
-
if(strcmp(str,WR_ANALYTICS_ON)==0) {
|
552
|
-
app->analytics = TRUE;
|
553
|
-
}
|
554
451
|
} else {
|
555
452
|
LOG_ERROR(SEVERE,"Application analytics for %s is missing. Application not started.",app_name);
|
556
453
|
printf("Application analytics for %s is missing. Application not started.\n",app_name);
|
@@ -561,7 +458,7 @@ static inline wr_app_conf_t* wr_app_conf_set (wr_conf_t* conf, node_t* app_node,
|
|
561
458
|
}
|
562
459
|
|
563
460
|
// Set application base uri
|
564
|
-
str = wr_validate_string(get_node_value(app_node->child,
|
461
|
+
str = wr_validate_string(get_node_value(app_node->child, "baseuri"));
|
565
462
|
if(str && strlen(str) > 0) {
|
566
463
|
len = strlen(str);
|
567
464
|
wr_string_new(app->baseuri, str, len);
|
@@ -569,21 +466,19 @@ static inline wr_app_conf_t* wr_app_conf_set (wr_conf_t* conf, node_t* app_node,
|
|
569
466
|
}
|
570
467
|
|
571
468
|
// Set Host names (used for multiple host deployment and application identifiaction)
|
572
|
-
str = wr_validate_string(get_node_value(app_node->child,
|
469
|
+
str = wr_validate_string(get_node_value(app_node->child, "host_names"));
|
573
470
|
if(str && strlen(str) > 0) {
|
574
471
|
wr_app_host_name_set(app, str, err_msg);
|
575
472
|
}
|
576
473
|
|
577
474
|
// Set application user & group id
|
578
|
-
str = wr_validate_string(get_node_value(app_node->child,
|
475
|
+
str = wr_validate_string(get_node_value(app_node->child, "run_as_user"));
|
579
476
|
if(str && strlen(str) > 0) {
|
477
|
+
len = strlen(str);
|
580
478
|
struct passwd *user_info=NULL;
|
581
479
|
user_info = getpwnam(str);
|
582
480
|
// Check for user existence
|
583
|
-
if(user_info) {
|
584
|
-
app->cuid = user_info->pw_uid;
|
585
|
-
app->cgid = user_info->pw_gid;
|
586
|
-
} else {
|
481
|
+
if(!user_info) {
|
587
482
|
LOG_ERROR(SEVERE,"Application run_as_user for %s is invalid. Application not started.",app_name);
|
588
483
|
printf("Application run_as_user for %s is invalid. Application not started.\n",app_name);
|
589
484
|
if(err_msg)
|
@@ -617,44 +512,33 @@ static inline wr_app_conf_t* wr_app_conf_set (wr_conf_t* conf, node_t* app_node,
|
|
617
512
|
}
|
618
513
|
|
619
514
|
// Set application environment
|
620
|
-
str = wr_validate_string(get_node_value(app_node->child,
|
515
|
+
str = wr_validate_string(get_node_value(app_node->child, "environment"));
|
621
516
|
if(str && strlen(str) > 0) {
|
622
|
-
|
623
|
-
wr_string_new(app->env, str, len);
|
624
|
-
LOG_DEBUG(DEBUG, "Application environment = %s", app->env.str);
|
625
|
-
} else {
|
626
|
-
len = strlen(WR_DEFAULT_ENV);
|
627
|
-
wr_string_new(app->env, WR_DEFAULT_ENV, len);
|
517
|
+
LOG_DEBUG(DEBUG, "Application environment = %s", str);
|
628
518
|
}
|
629
519
|
|
630
520
|
// Set min_worker
|
631
|
-
|
632
|
-
if(
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
sprintf(err_msg + strlen(err_msg), "Application(%s)-Minimum workers should be a number between 1 and %d. Application not started.", app_name, WR_ALLOWED_MAX_WORKERS);
|
639
|
-
free_app_obj = 1;
|
640
|
-
}
|
521
|
+
wr_set_numeric_value(app_node->child, "min_worker", &app->min_worker, FALSE);
|
522
|
+
if(app->min_worker > Config->Server.Worker.max) {
|
523
|
+
LOG_ERROR(SEVERE, "Application(%s)-Minimum workers should be a number between 1 and %d. Application not started.", app_name, Config->Server.Worker.max);
|
524
|
+
printf("Application(%s)-Minimum workers should be a number between 1 and %d. Application not started.\n", app_name, Config->Server.Worker.max);
|
525
|
+
if(err_msg)
|
526
|
+
sprintf(err_msg + strlen(err_msg), "Application(%s)-Minimum workers should be a number between 1 and %d. Application not started.", app_name, Config->Server.Worker.max);
|
527
|
+
free_app_obj = 1;
|
641
528
|
}
|
642
|
-
|
529
|
+
|
643
530
|
// Set max_worker
|
644
|
-
|
645
|
-
if(
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
sprintf(err_msg + strlen(err_msg), "Application(%s)-Maximum workers should be a number between 1 and %d. Application not started.", app_name, WR_ALLOWED_MAX_WORKERS);
|
652
|
-
free_app_obj = 1;
|
653
|
-
}
|
531
|
+
wr_set_numeric_value(app_node->child, "max_worker", &app->max_worker, FALSE);
|
532
|
+
if(app->max_worker > Config->Server.Worker.max) {
|
533
|
+
LOG_ERROR(SEVERE, "Application(%s)-Maximum workers should be a number between 1 and %d. Application not started.", app_name, Config->Server.Worker.max);
|
534
|
+
printf("Application(%s)-Maximum workers should be a number between 1 and %d. Application not started.\n", app_name, Config->Server.Worker.max);
|
535
|
+
if(err_msg)
|
536
|
+
sprintf(err_msg + strlen(err_msg), "Application(%s)-Maximum workers should be a number between 1 and %d. Application not started.", app_name, Config->Server.Worker.max);
|
537
|
+
free_app_obj = 1;
|
654
538
|
}
|
655
|
-
|
539
|
+
|
656
540
|
if(free_app_obj & 1) {
|
657
|
-
|
541
|
+
wr_application_list_free(app);
|
658
542
|
return NULL;
|
659
543
|
}
|
660
544
|
|
@@ -664,39 +548,47 @@ static inline wr_app_conf_t* wr_app_conf_set (wr_conf_t* conf, node_t* app_node,
|
|
664
548
|
printf("Application(%s) no. of min workers(%d) should not be greater than no. of max workers(%d). Application not started.\n",app_name, app->min_worker, app->max_worker);
|
665
549
|
if(err_msg)
|
666
550
|
sprintf(err_msg+strlen(err_msg),"\nApplication(%s) no. of min workers(%d) should not be greater than no. of max workers(%d). Application not started.",app_name, app->min_worker, app->max_worker);
|
667
|
-
|
551
|
+
wr_application_list_free(app);
|
668
552
|
return NULL;
|
669
553
|
}
|
670
554
|
|
671
555
|
// Set logging level
|
672
|
-
str = wr_validate_string(get_node_value(app_node->child,
|
673
|
-
if(str && strlen(str) > 0)
|
556
|
+
str = wr_validate_string(get_node_value(app_node->child, "log_level"));
|
557
|
+
if(str && strlen(str) > 0){
|
674
558
|
app->log_level = get_log_severity(str);
|
559
|
+
}
|
560
|
+
|
561
|
+
if(wr_app_conf_req_set(app, app_node) == FALSE){
|
562
|
+
wr_application_list_free(app);
|
563
|
+
return NULL;
|
564
|
+
}
|
565
|
+
|
675
566
|
return app;
|
676
567
|
}
|
677
568
|
|
678
569
|
/** Iterate application nodes and construct application configuration structure */
|
679
|
-
|
680
|
-
|
570
|
+
int wr_iterate_app_node(node_t *root) {
|
571
|
+
LOG_FUNCTION
|
572
|
+
config_application_list_t *app, *prev_app;
|
681
573
|
node_t* app_nodes;
|
682
574
|
|
683
575
|
LOG_DEBUG(DEBUG,"iterate_application_node()");
|
684
576
|
//Fetch Application Specification nodes
|
685
|
-
app_nodes = get_nodes(root,
|
577
|
+
app_nodes = get_nodes(root, "Application Specification");
|
686
578
|
|
687
579
|
// Iterate application nodes
|
688
580
|
while(app_nodes) {
|
689
581
|
if(app_nodes->child) {
|
690
582
|
// Create & fill application configuration structure
|
691
|
-
app =
|
583
|
+
app = wr_config_application_set(app_nodes, NULL);
|
692
584
|
|
693
585
|
if(app) {
|
694
586
|
//return -1;
|
695
587
|
// Set application configuration to configuration structure
|
696
|
-
if(
|
588
|
+
if(Config->Application.list) {
|
697
589
|
prev_app->next = app;
|
698
590
|
} else {
|
699
|
-
|
591
|
+
Config->Application.list = app;
|
700
592
|
}
|
701
593
|
prev_app = app;
|
702
594
|
}
|
@@ -707,9 +599,9 @@ static inline int wr_iterate_app_node(wr_conf_t *conf, node_t *root) {
|
|
707
599
|
}
|
708
600
|
|
709
601
|
/** Validate application baseuri for duplication. Also removes every such application object. */
|
710
|
-
|
602
|
+
int wr_remove_app_with_dup_baseuri() {
|
711
603
|
LOG_FUNCTION
|
712
|
-
|
604
|
+
config_application_list_t *app = Config->Application.list, *next,*tmp_app;
|
713
605
|
int rv = 0;
|
714
606
|
|
715
607
|
if(app == NULL) {
|
@@ -724,11 +616,11 @@ static inline int wr_remove_app_with_dup_baseuri(wr_conf_t *conf) {
|
|
724
616
|
if(app->baseuri.str) {
|
725
617
|
LOG_DEBUG(DEBUG, "Comparing baseuit %s ",app->baseuri.str) ;
|
726
618
|
// Compare each application baseuri with admin-panel baseuri
|
727
|
-
if(strcmp(app->baseuri.str,
|
728
|
-
LOG_ERROR(SEVERE,"'%s' base-uri is reserved for 'Admin Panel'. Application %s not started",
|
729
|
-
printf("'%s' base-uri is reserved for 'Admin Panel'. Application %s not started\n",
|
619
|
+
if(strcmp(app->baseuri.str, Config->Application.Admin_panel.base_uri.str)==0) {
|
620
|
+
LOG_ERROR(SEVERE,"'%s' base-uri is reserved for 'Admin Panel'. Application %s not started", Config->Application.Admin_panel.base_uri.str,app->name.str);
|
621
|
+
printf("'%s' base-uri is reserved for 'Admin Panel'. Application %s not started\n", Config->Application.Admin_panel.base_uri.str,app->name.str);
|
730
622
|
rv = -1;
|
731
|
-
wr_app_conf_remove(
|
623
|
+
wr_app_conf_remove(app->name.str);
|
732
624
|
} else {
|
733
625
|
tmp_app = next;
|
734
626
|
while(tmp_app) {
|
@@ -736,7 +628,7 @@ static inline int wr_remove_app_with_dup_baseuri(wr_conf_t *conf) {
|
|
736
628
|
LOG_ERROR(SEVERE,"Base-uri '%s' is repeated for more than one application.", app->baseuri.str);
|
737
629
|
printf("Base-uri '%s' is repeated for more than one application.\n",app->baseuri.str);
|
738
630
|
rv = -1;
|
739
|
-
wr_app_conf_remove(
|
631
|
+
wr_app_conf_remove(tmp_app->name.str);
|
740
632
|
tmp_app = next = app->next;
|
741
633
|
} else {
|
742
634
|
tmp_app = tmp_app->next;
|
@@ -750,10 +642,10 @@ static inline int wr_remove_app_with_dup_baseuri(wr_conf_t *conf) {
|
|
750
642
|
return rv;
|
751
643
|
}
|
752
644
|
|
753
|
-
|
645
|
+
int wr_chk_host_within_list(config_host_list_t *list) {
|
754
646
|
LOG_FUNCTION
|
755
647
|
|
756
|
-
|
648
|
+
config_host_list_t *tmp=NULL;
|
757
649
|
|
758
650
|
while(list) {
|
759
651
|
tmp = list->next;
|
@@ -768,7 +660,7 @@ static inline int wr_chk_host_within_list(wr_host_name_t *list) {
|
|
768
660
|
return 0;
|
769
661
|
}
|
770
662
|
|
771
|
-
|
663
|
+
int wr_chk_host_lists(config_host_list_t *list1, config_host_list_t *list2) {
|
772
664
|
LOG_FUNCTION
|
773
665
|
|
774
666
|
while(list1) {
|
@@ -784,9 +676,9 @@ static inline int wr_chk_host_lists(wr_host_name_t *list1, wr_host_name_t *list2
|
|
784
676
|
}
|
785
677
|
|
786
678
|
/** Removes Application object on repeated host_name. */
|
787
|
-
|
679
|
+
int wr_remove_app_with_dup_host() {
|
788
680
|
LOG_FUNCTION
|
789
|
-
|
681
|
+
config_application_list_t *app = Config->Application.list, *tmp_app = NULL;
|
790
682
|
short rv = 0;
|
791
683
|
|
792
684
|
if(app == NULL) {
|
@@ -802,7 +694,7 @@ static inline int wr_remove_app_with_dup_host(wr_conf_t *conf) {
|
|
802
694
|
if(wr_chk_host_within_list(app->host_name_list)!=0) {
|
803
695
|
LOG_ERROR(WARN,"Host names are repeated in Application '%s'. Application would not start.", app->name.str);
|
804
696
|
printf("Host names are repeated in Application '%s'. Application would not start.\n", app->name.str);
|
805
|
-
wr_app_conf_remove(
|
697
|
+
wr_app_conf_remove(app->name.str);
|
806
698
|
app = tmp_app;
|
807
699
|
rv = -1;
|
808
700
|
continue;
|
@@ -813,8 +705,8 @@ static inline int wr_remove_app_with_dup_host(wr_conf_t *conf) {
|
|
813
705
|
if(wr_chk_host_lists(app->host_name_list, tmp_app->host_name_list) !=0) {
|
814
706
|
LOG_ERROR(WARN,"Host names are repeated in '%s' and '%s'. Applications would not start.", app->name.str, tmp_app->name.str);
|
815
707
|
printf("Host names are repeated in '%s' and '%s'. Applications would not start.\n", app->name.str, tmp_app->name.str);
|
816
|
-
wr_app_conf_remove(
|
817
|
-
wr_app_conf_remove(
|
708
|
+
wr_app_conf_remove(app->name.str);
|
709
|
+
wr_app_conf_remove(tmp_app->name.str);
|
818
710
|
rv = -1;
|
819
711
|
break;
|
820
712
|
}
|
@@ -822,7 +714,7 @@ static inline int wr_remove_app_with_dup_host(wr_conf_t *conf) {
|
|
822
714
|
tmp_app = tmp_app->next;
|
823
715
|
}
|
824
716
|
if(tmp_app) {
|
825
|
-
app =
|
717
|
+
app = Config->Application.list;
|
826
718
|
continue;
|
827
719
|
}
|
828
720
|
}
|
@@ -832,47 +724,51 @@ static inline int wr_remove_app_with_dup_host(wr_conf_t *conf) {
|
|
832
724
|
}
|
833
725
|
|
834
726
|
/** Read Admin Panel */
|
835
|
-
|
727
|
+
config_application_list_t* wr_conf_admin_panel_read() {
|
836
728
|
LOG_FUNCTION
|
837
|
-
struct passwd *user_info=
|
838
|
-
|
839
|
-
|
840
|
-
user_info = getpwnam("root");
|
729
|
+
struct passwd *user_info = getpwnam("root");;
|
730
|
+
|
841
731
|
// Check for user privilege
|
842
732
|
if(user_info) {
|
843
733
|
if(geteuid() == user_info->pw_uid && getegid() == user_info->pw_gid) {
|
844
|
-
|
734
|
+
config_application_list_t* app = wr_config_application_new();
|
845
735
|
|
846
736
|
if(app ==NULL) {
|
847
737
|
return NULL;
|
848
738
|
}
|
739
|
+
|
740
|
+
app->scgi = scgi_new();
|
741
|
+
scgi_header_add(app->scgi, "COMPONENT", strlen("COMPONENT"), "WORKER", strlen("WORKER"));
|
742
|
+
scgi_header_add(app->scgi, "METHOD", strlen("METHOD"), "CONF_REQ", strlen("CONF_REQ"));
|
743
|
+
scgi_header_add(app->scgi, "STATUS", strlen("STATUS"), "OK", strlen("OK"));
|
744
|
+
|
849
745
|
|
850
746
|
// Set Admin base uri to 'admin-panel'
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
app->cuid = user_info->pw_uid;
|
857
|
-
|
747
|
+
wr_string_dump(app->baseuri, Config->Application.Admin_panel.base_uri);
|
748
|
+
scgi_header_add(app->scgi, "BASE_URI", strlen("BASE_URI"), app->baseuri.str, app->baseuri.len);
|
749
|
+
|
750
|
+
scgi_header_add(app->scgi, "USER", strlen("USER"), "root", strlen("root"));
|
751
|
+
|
858
752
|
// Set application environment to production
|
859
|
-
|
860
|
-
wr_string_new(app->env,"production",len);
|
753
|
+
scgi_header_add(app->scgi, "ENV", strlen("ENV"), "production",strlen("production"));
|
861
754
|
|
862
755
|
//Set max_worker & min_processsor to 1
|
863
756
|
app->max_worker = 1;
|
864
757
|
app->min_worker = 1;
|
865
758
|
|
866
759
|
// Set application name
|
867
|
-
|
868
|
-
|
869
|
-
|
760
|
+
wr_string_dump(app->name, Config->Application.Admin_panel.name);
|
761
|
+
scgi_header_add(app->scgi, "NAME", strlen("NAME"), app->name.str, app->name.len);
|
762
|
+
|
870
763
|
// Set Admin Panel path
|
871
|
-
wr_string_dump(app->path,
|
764
|
+
wr_string_dump(app->path, Config->Server.Dir.admin_panel);
|
765
|
+
scgi_header_add(app->scgi, "PATH", strlen("PATH"), Config->Server.Dir.admin_panel.str, Config->Server.Dir.admin_panel.len);
|
872
766
|
|
873
767
|
// Set application type to rails
|
874
|
-
|
875
|
-
|
768
|
+
scgi_header_add(app->scgi, "TYPE", strlen("TYPE"), "rails", strlen("rails"));
|
769
|
+
|
770
|
+
scgi_header_add(app->scgi, "ANALYTICS", strlen("ANALYTICS"), "disabled", strlen("disabled"));
|
771
|
+
scgi_build(app->scgi);
|
876
772
|
return app;
|
877
773
|
}
|
878
774
|
}
|
@@ -880,171 +776,253 @@ static inline wr_app_conf_t* wr_conf_admin_panel_read(wr_conf_t* conf) {
|
|
880
776
|
}
|
881
777
|
|
882
778
|
/** Create application configuration for static content server */
|
883
|
-
|
779
|
+
config_application_list_t* wr_conf_static_server_read() {
|
884
780
|
LOG_FUNCTION
|
885
781
|
struct passwd *user_info=NULL;
|
886
|
-
size_t len;
|
887
782
|
|
888
783
|
user_info = getpwnam("root");
|
889
784
|
// Check for user privilege
|
890
785
|
if(user_info) {
|
891
786
|
if(geteuid() == user_info->pw_uid && getegid() == user_info->pw_gid) {
|
892
|
-
|
787
|
+
config_application_list_t* app = wr_config_application_new();
|
788
|
+
node_t *root;
|
789
|
+
const char *value;
|
893
790
|
|
894
791
|
if(app == NULL) {
|
895
792
|
return NULL;
|
896
793
|
}
|
897
794
|
|
898
795
|
// Set application name
|
899
|
-
|
900
|
-
wr_string_new(app->name,WR_STATIC_FILE_SERVER_NAME,len);
|
796
|
+
wr_string_dump(app->name, Config->Application.Static_server.name);
|
901
797
|
|
902
798
|
//Set user & group id
|
903
|
-
app->cgid = user_info->pw_gid;
|
904
|
-
app->cuid = user_info->pw_uid;
|
905
799
|
|
906
800
|
// Set all other parameter to app name
|
907
|
-
wr_string_dump(app->env,app->name);
|
908
801
|
wr_string_dump(app->baseuri,app->name);
|
909
802
|
wr_string_dump(app->path,app->name);
|
910
|
-
|
803
|
+
|
804
|
+
app->scgi = scgi_new();
|
805
|
+
scgi_header_add(app->scgi, "COMPONENT", strlen("COMPONENT"), "WORKER", strlen("WORKER"));
|
806
|
+
scgi_header_add(app->scgi, "METHOD", strlen("METHOD"), "CONF_REQ", strlen("CONF_REQ"));
|
807
|
+
scgi_header_add(app->scgi, "STATUS", strlen("STATUS"), "OK", strlen("OK"));
|
808
|
+
|
809
|
+
root = yaml_parse(Config->Server.File.config.str);
|
810
|
+
|
811
|
+
if(!root) {
|
812
|
+
LOG_ERROR(SEVERE, "Config file found with erroneous entries. Please correct it.");
|
813
|
+
}else{
|
814
|
+
value = get_node_value(root,"Encoding/Content-Type");
|
815
|
+
if(value){
|
816
|
+
scgi_header_add(app->scgi, "CONTENT_TYPE", strlen("CONTENT_TYPE"), value, strlen(value));
|
817
|
+
}
|
818
|
+
|
819
|
+
value = get_node_value(root,"Encoding/User-Agent");
|
820
|
+
if(value){
|
821
|
+
scgi_header_add(app->scgi, "USER_AGENT", strlen("USER_AGENT"), value, strlen(value));
|
822
|
+
}
|
823
|
+
|
824
|
+
value = get_node_value(root,"Encoding/Size Limit/lower_limit");
|
825
|
+
if(value){
|
826
|
+
scgi_header_add(app->scgi, "LOWER_LIMIT", strlen("LOWER_LIMIT"), value, strlen(value));
|
827
|
+
}
|
828
|
+
|
829
|
+
value = get_node_value(root,"Encoding/Size Limit/upper_limit");
|
830
|
+
if(value){
|
831
|
+
scgi_header_add(app->scgi, "UPPER_LIMIT", strlen("UPPER_LIMIT"), value, strlen(value));
|
832
|
+
}
|
833
|
+
node_free(root);
|
834
|
+
}
|
911
835
|
|
912
836
|
//Set max_worker & min_processsor
|
913
|
-
app->max_worker =
|
914
|
-
app->min_worker =
|
915
|
-
|
837
|
+
app->max_worker = Config->Application.Static_server.max_workers;
|
838
|
+
app->min_worker = Config->Application.Static_server.min_workers;
|
839
|
+
|
840
|
+
scgi_build(app->scgi);
|
841
|
+
|
916
842
|
return app;
|
917
843
|
}
|
918
844
|
}
|
919
845
|
return NULL;
|
920
846
|
}
|
847
|
+
|
848
|
+
/** Search application configuration form application list */
|
849
|
+
config_application_list_t* wr_conf_app_exist(const char *app_name, config_application_list_t **prev_app){
|
850
|
+
config_application_list_t* app = Config->Application.list;
|
851
|
+
|
852
|
+
if(prev_app){
|
853
|
+
*prev_app = NULL;
|
854
|
+
while(app){
|
855
|
+
if(strcmp(app_name, app->name.str) == 0) //Compare application name
|
856
|
+
return app;
|
857
|
+
*prev_app = app;
|
858
|
+
app = app->next;
|
859
|
+
}
|
860
|
+
}else{
|
861
|
+
while(app){
|
862
|
+
if(strcmp(app_name, app->name.str) == 0) //Compare application name
|
863
|
+
return app;
|
864
|
+
app = app->next;
|
865
|
+
}
|
866
|
+
}
|
867
|
+
return NULL;
|
868
|
+
}
|
869
|
+
|
870
|
+
/** Read Application Configuration **/
|
871
|
+
void wr_application_conf_read(node_t *root){
|
872
|
+
wr_set_numeric_value(root, "Application/message_queue_size", &Config->Application.msg_queue_size, FALSE);
|
873
|
+
wr_set_numeric_value(root, "Application/maximum_request_ratio", &Config->Application.max_req_ratio, FALSE);
|
874
|
+
wr_set_numeric_value(root, "Application/minimum_request_ratio", &Config->Application.min_req_ratio, FALSE);
|
875
|
+
wr_set_numeric_value(root, "Application/high_load_time", &Config->Application.high_load, FALSE);
|
876
|
+
wr_set_numeric_value(root, "Application/low_load_time", &Config->Application.low_load, FALSE);
|
877
|
+
wr_set_numeric_value(root, "Application/maximum_hosts", &Config->Application.max_hosts, FALSE);
|
878
|
+
}
|
879
|
+
|
880
|
+
/** Read Worker Configuration **/
|
881
|
+
void wr_worker_conf_read(node_t *root){
|
882
|
+
wr_set_numeric_value(root, "Worker/maximum_request_body_size", &Config->Request.max_body_size, FALSE);
|
883
|
+
wr_set_numeric_value(root, "Worker/maximum_workers", &Config->Server.Worker.max, FALSE);
|
884
|
+
wr_set_numeric_value(root, "Worker/pending_workers", &Config->Server.Worker.pending, FALSE);
|
885
|
+
wr_set_numeric_value(root, "Worker/add_trials", &Config->Server.Worker.add_trials, FALSE);
|
886
|
+
wr_set_numeric_value(root, "Worker/add_wait", &Config->Server.Worker.add_wait, FALSE);
|
887
|
+
wr_set_numeric_value(root, "Worker/add_timeout", &Config->Server.Worker.add_timeout, TRUE);
|
888
|
+
wr_set_numeric_value(root, "Worker/kill_timeout", &Config->Server.Worker.kill_timeout, FALSE);
|
889
|
+
wr_set_numeric_value(root, "Worker/idle_time", &Config->Server.Worker.idle_time, TRUE);
|
890
|
+
wr_set_numeric_value(root, "Worker/ping_timeout", &Config->Server.Worker.ping_timeout, FALSE);
|
891
|
+
wr_set_numeric_value(root, "Worker/ping_trials", &Config->Server.Worker.ping_trials, FALSE);
|
892
|
+
}
|
893
|
+
|
894
|
+
/** Read and fill Server Internal Configuration **/
|
895
|
+
void wr_internal_conf_read(){
|
896
|
+
LOG_FUNCTION
|
897
|
+
node_t *root;
|
898
|
+
|
899
|
+
LOG_DEBUG(4,"YAML file path %s", Config->Server.File.internal_config.str);
|
900
|
+
root = yaml_parse(Config->Server.File.internal_config.str);
|
901
|
+
|
902
|
+
if(!root) {
|
903
|
+
LOG_ERROR(SEVERE, "Config file found with erroneous entries. Please correct it.");
|
904
|
+
printf("Config file found with erroneous entries. Please correct it.\n");
|
905
|
+
return;
|
906
|
+
}
|
907
|
+
|
908
|
+
wr_application_conf_read(root);
|
909
|
+
wr_worker_conf_read(root);
|
910
|
+
|
911
|
+
node_free(root);
|
912
|
+
}
|
913
|
+
|
921
914
|
/***********************************************************
|
922
915
|
* Configurator API definitions
|
923
916
|
************************************************************/
|
924
917
|
|
925
918
|
/** Remove specified application from configuraion */
|
926
|
-
int wr_app_conf_remove(
|
919
|
+
int wr_app_conf_remove(const char *app_name) {
|
927
920
|
LOG_FUNCTION
|
928
|
-
wr_app_conf_t* app = conf->apps, *tmp_app = NULL;
|
929
|
-
|
930
921
|
LOG_DEBUG(DEBUG, "Removing application %s", app_name);
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
tmp_app = app;
|
936
|
-
app = app->next;
|
937
|
-
}
|
922
|
+
config_application_list_t *app, *prev_app;
|
923
|
+
|
924
|
+
app = wr_conf_app_exist(app_name, &prev_app);
|
925
|
+
|
938
926
|
if(app) {
|
939
927
|
// Set application configuraion links
|
940
|
-
if(
|
941
|
-
|
928
|
+
if(prev_app) {
|
929
|
+
prev_app->next = app->next;
|
942
930
|
} else {
|
943
|
-
|
931
|
+
Config->Application.list = app->next;
|
944
932
|
}
|
945
933
|
app->next = NULL;
|
946
934
|
//Destroy application configuration
|
947
935
|
LOG_DEBUG(DEBUG, "Removed application %s", app->name.str);
|
948
|
-
|
936
|
+
wr_application_list_free(app);
|
949
937
|
return 0;
|
950
938
|
} else
|
951
939
|
return -1;
|
952
940
|
}
|
953
941
|
|
954
|
-
/** Replace the application configuration */
|
955
|
-
int wr_conf_app_replace(wr_conf_t *conf, wr_app_conf_t *app_conf){
|
956
|
-
LOG_FUNCTION
|
957
|
-
wr_app_conf_t *app = conf->apps, *tmp_app = NULL;
|
958
|
-
|
959
|
-
while(app) {
|
960
|
-
if(strcmp(app_conf->name.str, app->name.str)==0)
|
961
|
-
break;
|
962
|
-
tmp_app = app;
|
963
|
-
app = app->next;
|
964
|
-
}
|
965
|
-
|
966
|
-
if(app){
|
967
|
-
app_conf->next = app->next;
|
968
|
-
if(tmp_app){
|
969
|
-
tmp_app->next = app_conf;
|
970
|
-
}else{
|
971
|
-
conf->apps = app_conf;
|
972
|
-
}
|
973
|
-
app->next = NULL;
|
974
|
-
wr_conf_app_free(app);
|
975
|
-
}else{
|
976
|
-
LOG_ERROR(WARN, "Application '%s' is not found", app_conf->name.str);
|
977
|
-
app_conf->next = conf->apps;
|
978
|
-
conf->apps = app_conf;
|
979
|
-
}
|
980
|
-
return 0;
|
981
|
-
}
|
982
|
-
|
983
942
|
/** Remove the existing application specification if exists.
|
984
943
|
* And add the new application configuration. */
|
985
|
-
|
944
|
+
int wr_conf_app_update(config_application_list_t *app) {
|
986
945
|
LOG_FUNCTION
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
return
|
946
|
+
|
947
|
+
if(app == NULL) return FALSE;
|
948
|
+
|
949
|
+
wr_string_free(app->baseuri);
|
950
|
+
app->baseuri = app->new->baseuri;
|
951
|
+
|
952
|
+
wr_string_free(app->path);
|
953
|
+
app->path = app->new->path;
|
954
|
+
|
955
|
+
scgi_free(app->scgi);
|
956
|
+
app->scgi = app->new->scgi;
|
957
|
+
|
958
|
+
wr_host_list_free(app->host_name_list);
|
959
|
+
app->host_name_list = app->new->host_name_list;
|
960
|
+
|
961
|
+
app->min_worker = app->new->min_worker;
|
962
|
+
app->max_worker = app->new->max_worker;
|
963
|
+
app->log_level = app->new->log_level;
|
964
|
+
|
965
|
+
free(app->new);
|
966
|
+
app->new = NULL;
|
967
|
+
|
968
|
+
return TRUE;
|
1010
969
|
}
|
1011
970
|
|
1012
971
|
/** Read specified application and construct application configuration */
|
1013
|
-
|
972
|
+
// Flag to allow duplicate application
|
973
|
+
config_application_list_t* wr_conf_app_read(const char *app_name, char* err_msg, int flag) {
|
1014
974
|
LOG_FUNCTION
|
1015
975
|
//Parse configuration file
|
1016
976
|
node_t *root , *app_nodes = NULL;
|
1017
|
-
|
977
|
+
config_application_list_t *app = NULL, *old_app = NULL, *tmp;
|
1018
978
|
char *str;
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
979
|
+
|
980
|
+
old_app = wr_conf_app_exist(app_name, NULL);
|
981
|
+
|
982
|
+
if(flag == TRUE && old_app == NULL) return NULL;
|
983
|
+
if(flag == FALSE && old_app){
|
984
|
+
if(err_msg)
|
1025
985
|
sprintf(err_msg, "Application '%s' is already exists", app_name);
|
1026
|
-
|
1027
|
-
}
|
1028
|
-
app = app->next;
|
986
|
+
return NULL;
|
1029
987
|
}
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
if(strcmp(app_name, WR_ADMIN_PANEL_APP_NAME) == 0) {
|
1034
|
-
app = wr_conf_admin_panel_read(conf);
|
988
|
+
|
989
|
+
if(strcmp(app_name, Config->Application.Admin_panel.name.str) == 0) {
|
990
|
+
app = wr_conf_admin_panel_read();
|
1035
991
|
|
1036
992
|
if(app) {
|
1037
993
|
//Set application configuration into configuration data structure
|
1038
|
-
|
1039
|
-
|
994
|
+
if(flag == TRUE){
|
995
|
+
old_app->new = app;
|
996
|
+
return old_app;
|
997
|
+
}else{
|
998
|
+
app->next = Config->Application.list;
|
999
|
+
Config->Application.list = app;
|
1000
|
+
}
|
1040
1001
|
} else {
|
1041
1002
|
if(err_msg)
|
1042
1003
|
strcpy(err_msg, "Could not read Admin Panel");
|
1043
1004
|
}
|
1044
1005
|
return app;
|
1006
|
+
}else if(strcmp(app_name, Config->Application.Static_server.name.str) == 0){
|
1007
|
+
// Read Static server
|
1008
|
+
app = wr_conf_static_server_read();
|
1009
|
+
if(app) {
|
1010
|
+
//Set application configuration into configuration data structure
|
1011
|
+
if(flag == TRUE){
|
1012
|
+
old_app->new = app;
|
1013
|
+
return old_app;
|
1014
|
+
}else{
|
1015
|
+
app->next = Config->Application.list;
|
1016
|
+
Config->Application.list = app;
|
1017
|
+
}
|
1018
|
+
} else {
|
1019
|
+
if(err_msg)
|
1020
|
+
strcpy(err_msg, "Could not read Static Server");
|
1021
|
+
}
|
1022
|
+
return app;
|
1045
1023
|
}
|
1046
1024
|
|
1047
|
-
root = yaml_parse(
|
1025
|
+
root = yaml_parse(Config->Server.File.config.str);
|
1048
1026
|
|
1049
1027
|
if(!root) {
|
1050
1028
|
LOG_ERROR(SEVERE, "Config file found with erroneous entries. Please correct it.");
|
@@ -1057,15 +1035,14 @@ wr_app_conf_t* wr_conf_app_read(wr_conf_t* conf, const char *app_name, char* err
|
|
1057
1035
|
// return NULL;
|
1058
1036
|
// }
|
1059
1037
|
//Fetch Application Specification nodes
|
1060
|
-
app_nodes = get_nodes(root,
|
1038
|
+
app_nodes = get_nodes(root, "Application Specification");
|
1061
1039
|
|
1062
1040
|
// Iterate application nodes
|
1063
1041
|
while(app_nodes) {
|
1064
1042
|
if(app_nodes->child) {
|
1065
|
-
str = wr_validate_string(get_node_value(app_nodes->child,
|
1066
|
-
// Compare application name
|
1043
|
+
str = wr_validate_string(get_node_value(app_nodes->child, "name"));// Compare application name
|
1067
1044
|
if(str && strcmp(str, app_name)==0) {
|
1068
|
-
app =
|
1045
|
+
app = wr_config_application_set(app_nodes, err_msg);
|
1069
1046
|
break;
|
1070
1047
|
}
|
1071
1048
|
}
|
@@ -1073,149 +1050,106 @@ wr_app_conf_t* wr_conf_app_read(wr_conf_t* conf, const char *app_name, char* err
|
|
1073
1050
|
}
|
1074
1051
|
|
1075
1052
|
node_free(root);
|
1053
|
+
if(app == NULL) return NULL;
|
1054
|
+
|
1076
1055
|
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
if(app->host_name_list){
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
}
|
1056
|
+
// checking uniqueness for host name. While setting application object, we are parsing raw string of host_names
|
1057
|
+
// into host_name_list. We can easily check for uniqueness once host_name_list is ready.
|
1058
|
+
if(app->host_name_list){
|
1059
|
+
if(wr_chk_host_within_list(app->host_name_list)!=0) {
|
1060
|
+
LOG_ERROR(WARN,"Checking hosts within list is failed.");
|
1061
|
+
wr_application_list_free(app);
|
1062
|
+
return NULL;
|
1063
|
+
}
|
1086
1064
|
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
}
|
1065
|
+
tmp = Config->Application.list;
|
1066
|
+
while(tmp) {
|
1067
|
+
if(tmp->host_name_list && strcmp(tmp->name.str, app_name)!= 0 ) {
|
1068
|
+
if(wr_chk_host_lists(app->host_name_list, tmp->host_name_list)!=0) {
|
1069
|
+
LOG_ERROR(WARN,"Checking host lists is failed.");
|
1070
|
+
wr_application_list_free(app);
|
1071
|
+
return NULL;
|
1095
1072
|
}
|
1096
|
-
tmp = tmp->next;
|
1097
1073
|
}
|
1074
|
+
tmp = tmp->next;
|
1098
1075
|
}
|
1099
|
-
//Set application configuration into configuration data structure
|
1100
|
-
app->next = conf->apps;
|
1101
|
-
conf->apps = app;
|
1102
1076
|
}
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
wr_string_free(conf->server->sock_path);
|
1112
|
-
#ifdef HAVE_GNUTLS
|
1113
|
-
|
1114
|
-
wr_string_free(conf->server->certificate);
|
1115
|
-
wr_string_free(conf->server->key);
|
1116
|
-
#endif
|
1117
|
-
|
1118
|
-
free(conf->server);
|
1077
|
+
|
1078
|
+
//Set application configuration into configuration data structure
|
1079
|
+
if(flag == TRUE){
|
1080
|
+
old_app->new = app;
|
1081
|
+
return old_app;
|
1082
|
+
}else{
|
1083
|
+
app->next = Config->Application.list;
|
1084
|
+
Config->Application.list = app;
|
1119
1085
|
}
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
// Destroy configuration structure
|
1124
|
-
wr_string_free(conf->wr_root_path);
|
1125
|
-
wr_string_free(conf->ruby_lib_path);
|
1126
|
-
wr_string_free(conf->wkr_exe_path);
|
1127
|
-
wr_string_free(conf->admin_panel_path);
|
1128
|
-
wr_string_free(conf->config_file_path);
|
1129
|
-
free(conf);
|
1086
|
+
|
1087
|
+
return app;
|
1130
1088
|
}
|
1131
1089
|
|
1132
1090
|
/** Read configuration file and fill configuration object */
|
1133
|
-
|
1091
|
+
int wr_conf_read() {
|
1134
1092
|
LOG_FUNCTION
|
1135
1093
|
node_t *root;
|
1136
|
-
|
1137
|
-
|
1138
|
-
//Create configuration structure
|
1139
|
-
conf = wr_conf_new();
|
1140
|
-
if(conf == NULL) {
|
1141
|
-
LOG_ERROR(SEVERE,"Configuration object could not be allocated.");
|
1142
|
-
printf("Configuration object could not be allocated.\n");
|
1143
|
-
return NULL;
|
1144
|
-
}
|
1145
|
-
|
1146
|
-
// Initialize various paths based on webroar_root path
|
1147
|
-
wr_init_path(conf, root_path);
|
1094
|
+
|
1095
|
+
wr_internal_conf_read();
|
1148
1096
|
|
1149
1097
|
// Get parsed nodes
|
1150
|
-
LOG_DEBUG(4,"YAML file path %s",
|
1151
|
-
root = yaml_parse(
|
1098
|
+
LOG_DEBUG(4,"YAML file path %s", Config->Server.File.config.str);
|
1099
|
+
root = yaml_parse(Config->Server.File.config.str);
|
1152
1100
|
|
1153
1101
|
if(!root) {
|
1154
1102
|
LOG_ERROR(SEVERE, "Config file found with erroneous entries. Please correct it.");
|
1155
1103
|
printf("Config file found with erroneous entries. Please correct it.\n");
|
1156
|
-
|
1157
|
-
return NULL;
|
1104
|
+
return FALSE;
|
1158
1105
|
}
|
1159
1106
|
|
1160
1107
|
// Set server_configuration parameters
|
1161
|
-
|
1162
|
-
|
1163
|
-
goto conf_err;
|
1108
|
+
if(wr_config_server_set(root)!=0)
|
1109
|
+
return FALSE;
|
1164
1110
|
|
1165
1111
|
// Set application_configuration list
|
1166
|
-
wr_iterate_app_node(
|
1112
|
+
wr_iterate_app_node(root);
|
1167
1113
|
|
1168
|
-
wr_remove_app_with_dup_baseuri(
|
1114
|
+
wr_remove_app_with_dup_baseuri();
|
1169
1115
|
|
1170
|
-
wr_remove_app_with_dup_host(
|
1116
|
+
wr_remove_app_with_dup_host();
|
1171
1117
|
|
1172
1118
|
//configuration_print(configuration);
|
1173
1119
|
node_free(root);
|
1174
|
-
|
1175
|
-
return
|
1176
|
-
|
1177
|
-
conf_err:
|
1178
|
-
wr_conf_free(conf);
|
1179
|
-
return NULL;
|
1180
|
-
|
1120
|
+
|
1121
|
+
return TRUE;
|
1181
1122
|
}
|
1182
1123
|
|
1183
1124
|
/** Display configuration object */
|
1184
|
-
void wr_conf_display(
|
1125
|
+
void wr_conf_display() {
|
1185
1126
|
LOG_FUNCTION
|
1186
|
-
|
1127
|
+
config_application_list_t *app = Config->Application.list;
|
1187
1128
|
|
1188
1129
|
//printf("No of Applications : %d\n", conf->no_of_application);
|
1189
1130
|
|
1190
1131
|
// Display Server specification
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
printf("Access log flag : %d\n", conf->server->flag&WR_SVR_ACCESS_LOG);
|
1132
|
+
printf("Server log level : %d\n", Config->Server.log_level);
|
1133
|
+
printf("Server port : %d\n", Config->Server.port);
|
1134
|
+
printf("Server min worker : %d\n", Config->Application.Default.min_workers);
|
1135
|
+
printf("Server max worker : %d\n", Config->Application.Default.max_workers);
|
1136
|
+
printf("Access log flag : %d\n", Config->Server.flag & SERVER_ACCESS_LOG);
|
1197
1137
|
#ifdef HAVE_GNUTLS
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
printf("Server SSL port : %d\n", conf->server->ssl_port);
|
1138
|
+
printf("Server SSL certificate : %s\n", Config->Server.SSL.certificate.str);
|
1139
|
+
printf("Server SSL key : %s\n", Config->Server.SSL.key.str);
|
1140
|
+
printf("Server SSL port : %d\n", Config->Server.SSL.port);
|
1202
1141
|
#endif
|
1203
1142
|
|
1204
|
-
}
|
1205
|
-
|
1206
1143
|
// Display application specification
|
1207
1144
|
while(app) {
|
1208
1145
|
printf("Application log level : %d\n", app->log_level);
|
1209
|
-
printf("Environment : %s\n", app->env.str);
|
1210
1146
|
printf("Application min worker : %d\n", app->max_worker);
|
1211
1147
|
printf("Application max worker : %d\n", app->min_worker);
|
1212
1148
|
printf("Application name : %s\n", app->name.str);
|
1213
1149
|
printf("Application path : %s\n", app->path.str);
|
1214
|
-
printf("Application type : %s\n", app->type.str);
|
1215
|
-
printf("Application analytics : %d\n", app->analytics);
|
1216
1150
|
printf("Application baseuri : %s\n", app->baseuri.str);
|
1217
1151
|
if(app->host_name_list) {
|
1218
|
-
|
1152
|
+
config_host_list_t* host=app->host_name_list;
|
1219
1153
|
printf("Host Name List :- \n");
|
1220
1154
|
while(host) {
|
1221
1155
|
printf("%s, ", host->name.str);
|
@@ -1228,13 +1162,13 @@ void wr_conf_display(wr_conf_t* conf) {
|
|
1228
1162
|
}
|
1229
1163
|
|
1230
1164
|
/** Add Admin Panel configuration */
|
1231
|
-
int wr_conf_admin_panel_add(
|
1165
|
+
int wr_conf_admin_panel_add() {
|
1232
1166
|
LOG_FUNCTION
|
1233
|
-
|
1167
|
+
config_application_list_t* app = wr_conf_admin_panel_read();
|
1234
1168
|
|
1235
1169
|
if(app != NULL) {
|
1236
|
-
app->next =
|
1237
|
-
|
1170
|
+
app->next = Config->Application.list;
|
1171
|
+
Config->Application.list = app;
|
1238
1172
|
return 0;
|
1239
1173
|
} else {
|
1240
1174
|
printf("'Admin Panel' could not be started. To start 'Admin Panel' run server with root privileges.\n");
|
@@ -1244,13 +1178,13 @@ int wr_conf_admin_panel_add(wr_conf_t* conf) {
|
|
1244
1178
|
}
|
1245
1179
|
|
1246
1180
|
/** Add the configuration for static content server */
|
1247
|
-
int wr_conf_static_server_add(
|
1181
|
+
int wr_conf_static_server_add() {
|
1248
1182
|
LOG_FUNCTION
|
1249
|
-
|
1183
|
+
config_application_list_t* app = wr_conf_static_server_read();
|
1250
1184
|
|
1251
1185
|
if(app != NULL) {
|
1252
|
-
app->next =
|
1253
|
-
|
1186
|
+
app->next = Config->Application.list;
|
1187
|
+
Config->Application.list = app;
|
1254
1188
|
return 0;
|
1255
1189
|
}
|
1256
1190
|
|