summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_application.c
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2017-07-12 20:32:16 +0300
committerMax Romanov <max.romanov@nginx.com>2017-07-12 20:32:16 +0300
commitb0c1e740cf404f8fed5eed75fddb205ca74314e0 (patch)
tree08dcefc827c5dfb1570b682ea8d1e9abf17a31dc /src/nxt_application.c
parentc38bcb7d70729434893ae4d5f2f58a78a36d2bd5 (diff)
downloadunit-b0c1e740cf404f8fed5eed75fddb205ca74314e0.tar.gz
unit-b0c1e740cf404f8fed5eed75fddb205ca74314e0.tar.bz2
New process port exchange changed. READY message type introduced.
Application process start request DATA message from router to master. Master notifies router via NEW_PORT message after worker process become ready.
Diffstat (limited to 'src/nxt_application.c')
-rw-r--r--src/nxt_application.c58
1 files changed, 53 insertions, 5 deletions
diff --git a/src/nxt_application.c b/src/nxt_application.c
index 37e2577c..50feac2d 100644
--- a/src/nxt_application.c
+++ b/src/nxt_application.c
@@ -9,19 +9,27 @@
#include <nxt_main.h>
#include <nxt_runtime.h>
#include <nxt_application.h>
+#include <nxt_master_process.h>
-nxt_application_module_t *nxt_app;
+nxt_application_module_t *nxt_app_modules[NXT_APP_MAX];
static nxt_thread_mutex_t nxt_app_mutex;
static nxt_thread_cond_t nxt_app_cond;
static nxt_http_fields_hash_entry_t nxt_app_request_fields[];
-static nxt_http_fields_hash_t *nxt_app_request_fields_hash;
+static nxt_http_fields_hash_t *nxt_app_request_fields_hash;
+
+static nxt_application_module_t *nxt_app;
nxt_int_t
-nxt_app_start(nxt_task_t *task, nxt_runtime_t *rt)
+nxt_app_start(nxt_task_t *task, void *data)
{
+ nxt_int_t ret;
+ nxt_common_app_conf_t *app_conf;
+
+ app_conf = data;
+
if (nxt_slow_path(nxt_thread_mutex_create(&nxt_app_mutex) != NXT_OK)) {
return NXT_ERROR;
}
@@ -30,11 +38,18 @@ nxt_app_start(nxt_task_t *task, nxt_runtime_t *rt)
return NXT_ERROR;
}
- if (nxt_slow_path(nxt_app->init(task) != NXT_OK)) {
+ nxt_app = nxt_app_modules[app_conf->type_id];
+
+ ret = nxt_app->init(task, data);
+
+ if (nxt_slow_path(ret != NXT_OK)) {
nxt_debug(task, "application init failed");
+
+ } else {
+ nxt_debug(task, "application init done");
}
- return NXT_OK;
+ return ret;
}
@@ -570,3 +585,36 @@ nxt_app_msg_write_raw(nxt_task_t *task, nxt_app_wmsg_t *msg, const u_char *c,
return NXT_OK;
}
+
+
+nxt_app_type_t
+nxt_app_parse_type(nxt_str_t *str)
+{
+ if (nxt_str_eq(str, "python", 6)) {
+ return NXT_APP_PYTHON;
+
+ } else if (nxt_str_eq(str, "python2", 7)) {
+ return NXT_APP_PYTHON2;
+
+ } else if (nxt_str_eq(str, "python3", 7)) {
+ return NXT_APP_PYTHON3;
+
+ } else if (nxt_str_eq(str, "php", 3)) {
+ return NXT_APP_PHP;
+
+ } else if (nxt_str_eq(str, "php5", 4)) {
+ return NXT_APP_PHP5;
+
+ } else if (nxt_str_eq(str, "php7", 4)) {
+ return NXT_APP_PHP7;
+
+ } else if (nxt_str_eq(str, "ruby", 4)) {
+ return NXT_APP_RUBY;
+
+ } else if (nxt_str_eq(str, "go", 2)) {
+ return NXT_APP_GO;
+
+ }
+
+ return NXT_APP_UNKNOWN;
+}