Renamed "go" application type to "external".
There's nothing specific to Go language. This type of application object can be used to run any external application that utilizes libunit API.
This commit is contained in:
@@ -84,7 +84,7 @@ NXT_LIB_SRCS=" \
|
|||||||
src/nxt_http_response.c \
|
src/nxt_http_response.c \
|
||||||
src/nxt_http_error.c \
|
src/nxt_http_error.c \
|
||||||
src/nxt_application.c \
|
src/nxt_application.c \
|
||||||
src/nxt_go.c \
|
src/nxt_external.c \
|
||||||
src/nxt_port_hash.c \
|
src/nxt_port_hash.c \
|
||||||
"
|
"
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"applications": {
|
"applications": {
|
||||||
"example_go": {
|
"example_go": {
|
||||||
"type": "go",
|
"type": "external",
|
||||||
"user": "nobody",
|
"user": "nobody",
|
||||||
"executable": "/tmp/go-app"
|
"executable": "/tmp/go-app"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"applications": {
|
"applications": {
|
||||||
"example_go": {
|
"example_go": {
|
||||||
"type": "go",
|
"type": "external",
|
||||||
"user": "nobody",
|
"user": "nobody",
|
||||||
"executable": "/tmp/go1.10-app"
|
"executable": "/tmp/go1.10-app"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"applications": {
|
"applications": {
|
||||||
"example_go": {
|
"example_go": {
|
||||||
"type": "go",
|
"type": "external",
|
||||||
"user": "nobody",
|
"user": "nobody",
|
||||||
"executable": "/tmp/go1.7-app"
|
"executable": "/tmp/go1.7-app"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"applications": {
|
"applications": {
|
||||||
"example_go": {
|
"example_go": {
|
||||||
"type": "go",
|
"type": "external",
|
||||||
"user": "nobody",
|
"user": "nobody",
|
||||||
"executable": "/tmp/go1.8-app"
|
"executable": "/tmp/go1.8-app"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"applications": {
|
"applications": {
|
||||||
"example_go": {
|
"example_go": {
|
||||||
"type": "go",
|
"type": "external",
|
||||||
"user": "nobody",
|
"user": "nobody",
|
||||||
"executable": "/tmp/go1.9-app"
|
"executable": "/tmp/go1.9-app"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
"example_go": {
|
"example_go": {
|
||||||
"type": "go",
|
"type": "external",
|
||||||
"user": "nobody",
|
"user": "nobody",
|
||||||
"executable": "/tmp/go-app"
|
"executable": "/tmp/go-app"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"applications": {
|
"applications": {
|
||||||
"example_go": {
|
"example_go": {
|
||||||
"type": "go",
|
"type": "external",
|
||||||
"user": "nobody",
|
"user": "nobody",
|
||||||
"executable": "/tmp/go-app"
|
"executable": "/tmp/go-app"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
"example_go": {
|
"example_go": {
|
||||||
"type": "go",
|
"type": "external",
|
||||||
"user": "nobody",
|
"user": "nobody",
|
||||||
"executable": "/tmp/go-app"
|
"executable": "/tmp/go-app"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -507,15 +507,15 @@ nxt_app_parse_type(u_char *p, size_t length)
|
|||||||
str.length = length;
|
str.length = length;
|
||||||
str.start = p;
|
str.start = p;
|
||||||
|
|
||||||
if (nxt_str_eq(&str, "python", 6)) {
|
if (nxt_str_eq(&str, "external", 8) || nxt_str_eq(&str, "go", 2)) {
|
||||||
|
return NXT_APP_EXTERNAL;
|
||||||
|
|
||||||
|
} else if (nxt_str_eq(&str, "python", 6)) {
|
||||||
return NXT_APP_PYTHON;
|
return NXT_APP_PYTHON;
|
||||||
|
|
||||||
} else if (nxt_str_eq(&str, "php", 3)) {
|
} else if (nxt_str_eq(&str, "php", 3)) {
|
||||||
return NXT_APP_PHP;
|
return NXT_APP_PHP;
|
||||||
|
|
||||||
} else if (nxt_str_eq(&str, "go", 2)) {
|
|
||||||
return NXT_APP_GO;
|
|
||||||
|
|
||||||
} else if (nxt_str_eq(&str, "perl", 4)) {
|
} else if (nxt_str_eq(&str, "perl", 4)) {
|
||||||
return NXT_APP_PERL;
|
return NXT_APP_PERL;
|
||||||
|
|
||||||
|
|||||||
@@ -15,9 +15,9 @@
|
|||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
NXT_APP_EXTERNAL,
|
||||||
NXT_APP_PYTHON,
|
NXT_APP_PYTHON,
|
||||||
NXT_APP_PHP,
|
NXT_APP_PHP,
|
||||||
NXT_APP_GO,
|
|
||||||
NXT_APP_PERL,
|
NXT_APP_PERL,
|
||||||
NXT_APP_RUBY,
|
NXT_APP_RUBY,
|
||||||
|
|
||||||
@@ -39,6 +39,12 @@ typedef struct {
|
|||||||
typedef struct nxt_common_app_conf_s nxt_common_app_conf_t;
|
typedef struct nxt_common_app_conf_s nxt_common_app_conf_t;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char *executable;
|
||||||
|
nxt_conf_value_t *arguments;
|
||||||
|
} nxt_external_app_conf_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *home;
|
char *home;
|
||||||
nxt_str_t path;
|
nxt_str_t path;
|
||||||
@@ -54,12 +60,6 @@ typedef struct {
|
|||||||
} nxt_php_app_conf_t;
|
} nxt_php_app_conf_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
char *executable;
|
|
||||||
nxt_conf_value_t *arguments;
|
|
||||||
} nxt_go_app_conf_t;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *script;
|
char *script;
|
||||||
} nxt_perl_app_conf_t;
|
} nxt_perl_app_conf_t;
|
||||||
@@ -80,9 +80,9 @@ struct nxt_common_app_conf_s {
|
|||||||
nxt_conf_value_t *environment;
|
nxt_conf_value_t *environment;
|
||||||
|
|
||||||
union {
|
union {
|
||||||
|
nxt_external_app_conf_t external;
|
||||||
nxt_python_app_conf_t python;
|
nxt_python_app_conf_t python;
|
||||||
nxt_php_app_conf_t php;
|
nxt_php_app_conf_t php;
|
||||||
nxt_go_app_conf_t go;
|
|
||||||
nxt_perl_app_conf_t perl;
|
nxt_perl_app_conf_t perl;
|
||||||
nxt_ruby_app_conf_t ruby;
|
nxt_ruby_app_conf_t ruby;
|
||||||
} u;
|
} u;
|
||||||
@@ -161,7 +161,7 @@ nxt_app_lang_module_t *nxt_app_lang_module(nxt_runtime_t *rt, nxt_str_t *name);
|
|||||||
nxt_app_type_t nxt_app_parse_type(u_char *p, size_t length);
|
nxt_app_type_t nxt_app_parse_type(u_char *p, size_t length);
|
||||||
|
|
||||||
NXT_EXPORT extern nxt_str_t nxt_server;
|
NXT_EXPORT extern nxt_str_t nxt_server;
|
||||||
extern nxt_app_module_t nxt_go_module;
|
extern nxt_app_module_t nxt_external_module;
|
||||||
|
|
||||||
NXT_EXPORT nxt_int_t nxt_unit_default_init(nxt_task_t *task,
|
NXT_EXPORT nxt_int_t nxt_unit_default_init(nxt_task_t *task,
|
||||||
nxt_unit_init_t *init);
|
nxt_unit_init_t *init);
|
||||||
|
|||||||
@@ -256,6 +256,21 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_common_members[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static nxt_conf_vldt_object_t nxt_conf_vldt_external_members[] = {
|
||||||
|
{ nxt_string("executable"),
|
||||||
|
NXT_CONF_VLDT_STRING,
|
||||||
|
NULL,
|
||||||
|
NULL },
|
||||||
|
|
||||||
|
{ nxt_string("arguments"),
|
||||||
|
NXT_CONF_VLDT_ARRAY,
|
||||||
|
&nxt_conf_vldt_array_iterator,
|
||||||
|
(void *) &nxt_conf_vldt_argument },
|
||||||
|
|
||||||
|
NXT_CONF_VLDT_NEXT(&nxt_conf_vldt_common_members)
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
static nxt_conf_vldt_object_t nxt_conf_vldt_python_members[] = {
|
static nxt_conf_vldt_object_t nxt_conf_vldt_python_members[] = {
|
||||||
{ nxt_string("home"),
|
{ nxt_string("home"),
|
||||||
NXT_CONF_VLDT_STRING,
|
NXT_CONF_VLDT_STRING,
|
||||||
@@ -321,21 +336,6 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_php_members[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static nxt_conf_vldt_object_t nxt_conf_vldt_go_members[] = {
|
|
||||||
{ nxt_string("executable"),
|
|
||||||
NXT_CONF_VLDT_STRING,
|
|
||||||
NULL,
|
|
||||||
NULL },
|
|
||||||
|
|
||||||
{ nxt_string("arguments"),
|
|
||||||
NXT_CONF_VLDT_ARRAY,
|
|
||||||
&nxt_conf_vldt_array_iterator,
|
|
||||||
(void *) &nxt_conf_vldt_argument },
|
|
||||||
|
|
||||||
NXT_CONF_VLDT_NEXT(&nxt_conf_vldt_common_members)
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static nxt_conf_vldt_object_t nxt_conf_vldt_perl_members[] = {
|
static nxt_conf_vldt_object_t nxt_conf_vldt_perl_members[] = {
|
||||||
{ nxt_string("script"),
|
{ nxt_string("script"),
|
||||||
NXT_CONF_VLDT_STRING,
|
NXT_CONF_VLDT_STRING,
|
||||||
@@ -565,9 +565,9 @@ nxt_conf_vldt_app(nxt_conf_validation_t *vldt, nxt_str_t *name,
|
|||||||
static nxt_str_t type_str = nxt_string("type");
|
static nxt_str_t type_str = nxt_string("type");
|
||||||
|
|
||||||
static void *members[] = {
|
static void *members[] = {
|
||||||
|
nxt_conf_vldt_external_members,
|
||||||
nxt_conf_vldt_python_members,
|
nxt_conf_vldt_python_members,
|
||||||
nxt_conf_vldt_php_members,
|
nxt_conf_vldt_php_members,
|
||||||
nxt_conf_vldt_go_members,
|
|
||||||
nxt_conf_vldt_perl_members,
|
nxt_conf_vldt_perl_members,
|
||||||
nxt_conf_vldt_ruby_members,
|
nxt_conf_vldt_ruby_members,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,21 +9,24 @@
|
|||||||
#include <nxt_unit.h>
|
#include <nxt_unit.h>
|
||||||
|
|
||||||
|
|
||||||
static nxt_int_t nxt_go_init(nxt_task_t *task, nxt_common_app_conf_t *conf);
|
static nxt_int_t nxt_external_init(nxt_task_t *task,
|
||||||
|
nxt_common_app_conf_t *conf);
|
||||||
|
|
||||||
nxt_app_module_t nxt_go_module = {
|
|
||||||
|
nxt_app_module_t nxt_external_module = {
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
nxt_string("go"),
|
nxt_string("external"),
|
||||||
"*",
|
"*",
|
||||||
nxt_go_init,
|
nxt_external_init,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
|
||||||
|
|
||||||
nxt_inline nxt_int_t
|
nxt_inline nxt_int_t
|
||||||
nxt_go_fd_no_cloexec(nxt_task_t *task, nxt_socket_t fd)
|
nxt_external_fd_no_cloexec(nxt_task_t *task, nxt_socket_t fd)
|
||||||
{
|
{
|
||||||
int res, flags;
|
int res, flags;
|
||||||
|
|
||||||
@@ -54,7 +57,7 @@ nxt_go_fd_no_cloexec(nxt_task_t *task, nxt_socket_t fd)
|
|||||||
|
|
||||||
|
|
||||||
static nxt_int_t
|
static nxt_int_t
|
||||||
nxt_go_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
|
nxt_external_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
|
||||||
{
|
{
|
||||||
char **argv;
|
char **argv;
|
||||||
u_char buf[256];
|
u_char buf[256];
|
||||||
@@ -67,7 +70,7 @@ nxt_go_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
|
|||||||
nxt_port_t *my_port, *main_port;
|
nxt_port_t *my_port, *main_port;
|
||||||
nxt_runtime_t *rt;
|
nxt_runtime_t *rt;
|
||||||
nxt_conf_value_t *value;
|
nxt_conf_value_t *value;
|
||||||
nxt_go_app_conf_t *c;
|
nxt_external_app_conf_t *c;
|
||||||
|
|
||||||
rt = task->thread->runtime;
|
rt = task->thread->runtime;
|
||||||
|
|
||||||
@@ -78,12 +81,12 @@ nxt_go_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
|
|||||||
return NXT_ERROR;
|
return NXT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = nxt_go_fd_no_cloexec(task, main_port->pair[1]);
|
rc = nxt_external_fd_no_cloexec(task, main_port->pair[1]);
|
||||||
if (nxt_slow_path(rc != NXT_OK)) {
|
if (nxt_slow_path(rc != NXT_OK)) {
|
||||||
return NXT_ERROR;
|
return NXT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = nxt_go_fd_no_cloexec(task, my_port->pair[0]);
|
rc = nxt_external_fd_no_cloexec(task, my_port->pair[0]);
|
||||||
if (nxt_slow_path(rc != NXT_OK)) {
|
if (nxt_slow_path(rc != NXT_OK)) {
|
||||||
return NXT_ERROR;
|
return NXT_ERROR;
|
||||||
}
|
}
|
||||||
@@ -116,7 +119,7 @@ nxt_go_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
|
|||||||
return NXT_ERROR;
|
return NXT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
c = &conf->u.go;
|
c = &conf->u.external;
|
||||||
|
|
||||||
argc = 2;
|
argc = 2;
|
||||||
size = 0;
|
size = 0;
|
||||||
@@ -134,6 +134,22 @@ static nxt_conf_map_t nxt_common_app_conf[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static nxt_conf_map_t nxt_external_app_conf[] = {
|
||||||
|
{
|
||||||
|
nxt_string("executable"),
|
||||||
|
NXT_CONF_MAP_CSTRZ,
|
||||||
|
offsetof(nxt_common_app_conf_t, u.external.executable),
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
nxt_string("arguments"),
|
||||||
|
NXT_CONF_MAP_PTR,
|
||||||
|
offsetof(nxt_common_app_conf_t, u.external.arguments),
|
||||||
|
},
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
static nxt_conf_map_t nxt_python_app_conf[] = {
|
static nxt_conf_map_t nxt_python_app_conf[] = {
|
||||||
{
|
{
|
||||||
nxt_string("home"),
|
nxt_string("home"),
|
||||||
@@ -182,22 +198,6 @@ static nxt_conf_map_t nxt_php_app_conf[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static nxt_conf_map_t nxt_go_app_conf[] = {
|
|
||||||
{
|
|
||||||
nxt_string("executable"),
|
|
||||||
NXT_CONF_MAP_CSTRZ,
|
|
||||||
offsetof(nxt_common_app_conf_t, u.go.executable),
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
nxt_string("arguments"),
|
|
||||||
NXT_CONF_MAP_PTR,
|
|
||||||
offsetof(nxt_common_app_conf_t, u.go.arguments),
|
|
||||||
},
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static nxt_conf_map_t nxt_perl_app_conf[] = {
|
static nxt_conf_map_t nxt_perl_app_conf[] = {
|
||||||
{
|
{
|
||||||
nxt_string("script"),
|
nxt_string("script"),
|
||||||
@@ -217,9 +217,9 @@ static nxt_conf_map_t nxt_ruby_app_conf[] = {
|
|||||||
|
|
||||||
|
|
||||||
static nxt_conf_app_map_t nxt_app_maps[] = {
|
static nxt_conf_app_map_t nxt_app_maps[] = {
|
||||||
|
{ nxt_nitems(nxt_external_app_conf), nxt_external_app_conf },
|
||||||
{ nxt_nitems(nxt_python_app_conf), nxt_python_app_conf },
|
{ nxt_nitems(nxt_python_app_conf), nxt_python_app_conf },
|
||||||
{ nxt_nitems(nxt_php_app_conf), nxt_php_app_conf },
|
{ nxt_nitems(nxt_php_app_conf), nxt_php_app_conf },
|
||||||
{ nxt_nitems(nxt_go_app_conf), nxt_go_app_conf },
|
|
||||||
{ nxt_nitems(nxt_perl_app_conf), nxt_perl_app_conf },
|
{ nxt_nitems(nxt_perl_app_conf), nxt_perl_app_conf },
|
||||||
{ nxt_nitems(nxt_ruby_app_conf), nxt_ruby_app_conf },
|
{ nxt_nitems(nxt_ruby_app_conf), nxt_ruby_app_conf },
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -289,11 +289,11 @@ static const nxt_str_t http_prefix = nxt_string("HTTP_");
|
|||||||
static const nxt_str_t empty_prefix = nxt_string("");
|
static const nxt_str_t empty_prefix = nxt_string("");
|
||||||
|
|
||||||
static const nxt_str_t *nxt_app_msg_prefix[] = {
|
static const nxt_str_t *nxt_app_msg_prefix[] = {
|
||||||
&http_prefix,
|
|
||||||
&http_prefix,
|
|
||||||
&empty_prefix,
|
&empty_prefix,
|
||||||
&http_prefix,
|
&http_prefix,
|
||||||
&http_prefix,
|
&http_prefix,
|
||||||
|
&http_prefix,
|
||||||
|
&http_prefix,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -80,10 +80,10 @@ nxt_runtime_create(nxt_task_t *task)
|
|||||||
|
|
||||||
/* Should not fail. */
|
/* Should not fail. */
|
||||||
lang = nxt_array_add(rt->languages);
|
lang = nxt_array_add(rt->languages);
|
||||||
lang->type = NXT_APP_GO;
|
lang->type = NXT_APP_EXTERNAL;
|
||||||
lang->version = (u_char *) "";
|
lang->version = (u_char *) "";
|
||||||
lang->file = NULL;
|
lang->file = NULL;
|
||||||
lang->module = &nxt_go_module;
|
lang->module = &nxt_external_module;
|
||||||
|
|
||||||
listen_sockets = nxt_array_create(mp, 1, sizeof(nxt_listen_socket_t));
|
listen_sockets = nxt_array_create(mp, 1, sizeof(nxt_listen_socket_t));
|
||||||
if (nxt_slow_path(listen_sockets == NULL)) {
|
if (nxt_slow_path(listen_sockets == NULL)) {
|
||||||
|
|||||||
@@ -477,7 +477,7 @@ class TestUnitApplicationGo(TestUnitApplicationProto):
|
|||||||
},
|
},
|
||||||
"applications": {
|
"applications": {
|
||||||
script: {
|
script: {
|
||||||
"type": "go",
|
"type": "external",
|
||||||
"processes": { "spare": 0 },
|
"processes": { "spare": 0 },
|
||||||
"working_directory": self.current_dir + '/go/' + script,
|
"working_directory": self.current_dir + '/go/' + script,
|
||||||
"executable": self.testdir + '/go/' + name
|
"executable": self.testdir + '/go/' + name
|
||||||
|
|||||||
Reference in New Issue
Block a user