nxt_application.h (1601:365bbeccef1c) nxt_application.h (1681:542b5b8c0647)
1
2/*
3 * Copyright (C) Max Romanov
4 * Copyright (C) Valentin V. Bartenev
5 * Copyright (C) NGINX, Inc.
6 */
7
8#ifndef _NXT_APPLICATION_H_INCLUDED_
9#define _NXT_APPLICATION_H_INCLUDED_
10
11
12#include <nxt_conf.h>
13
14#include <nxt_unit_typedefs.h>
15
16
17typedef enum {
18 NXT_APP_EXTERNAL,
19 NXT_APP_PYTHON,
20 NXT_APP_PHP,
21 NXT_APP_PERL,
22 NXT_APP_RUBY,
23 NXT_APP_JAVA,
24
25 NXT_APP_UNKNOWN,
26} nxt_app_type_t;
27
28
29typedef struct nxt_app_module_s nxt_app_module_t;
30typedef nxt_int_t (*nxt_application_setup_t)(nxt_task_t *task,
31 nxt_process_t *process, nxt_common_app_conf_t *conf);
32
33
34typedef struct {
35 nxt_app_type_t type;
36 u_char *version;
37 char *file;
38 nxt_app_module_t *module;
39 nxt_array_t *mounts; /* of nxt_fs_mount_t */
40} nxt_app_lang_module_t;
41
42
43typedef struct {
44 char *executable;
45 nxt_conf_value_t *arguments;
46} nxt_external_app_conf_t;
47
48
49typedef struct {
50 char *home;
51 nxt_str_t path;
52 nxt_str_t module;
53 char *callable;
1
2/*
3 * Copyright (C) Max Romanov
4 * Copyright (C) Valentin V. Bartenev
5 * Copyright (C) NGINX, Inc.
6 */
7
8#ifndef _NXT_APPLICATION_H_INCLUDED_
9#define _NXT_APPLICATION_H_INCLUDED_
10
11
12#include <nxt_conf.h>
13
14#include <nxt_unit_typedefs.h>
15
16
17typedef enum {
18 NXT_APP_EXTERNAL,
19 NXT_APP_PYTHON,
20 NXT_APP_PHP,
21 NXT_APP_PERL,
22 NXT_APP_RUBY,
23 NXT_APP_JAVA,
24
25 NXT_APP_UNKNOWN,
26} nxt_app_type_t;
27
28
29typedef struct nxt_app_module_s nxt_app_module_t;
30typedef nxt_int_t (*nxt_application_setup_t)(nxt_task_t *task,
31 nxt_process_t *process, nxt_common_app_conf_t *conf);
32
33
34typedef struct {
35 nxt_app_type_t type;
36 u_char *version;
37 char *file;
38 nxt_app_module_t *module;
39 nxt_array_t *mounts; /* of nxt_fs_mount_t */
40} nxt_app_lang_module_t;
41
42
43typedef struct {
44 char *executable;
45 nxt_conf_value_t *arguments;
46} nxt_external_app_conf_t;
47
48
49typedef struct {
50 char *home;
51 nxt_str_t path;
52 nxt_str_t module;
53 char *callable;
54 uint32_t threads;
55 uint32_t thread_stack_size;
54} nxt_python_app_conf_t;
55
56
57typedef struct {
58 nxt_conf_value_t *targets;
59 nxt_conf_value_t *options;
60} nxt_php_app_conf_t;
61
62
63typedef struct {
64 char *script;
65} nxt_perl_app_conf_t;
66
67
68typedef struct {
69 nxt_str_t script;
70} nxt_ruby_app_conf_t;
71
72
73typedef struct {
74 nxt_conf_value_t *classpath;
75 char *webapp;
76 nxt_conf_value_t *options;
77 char *unit_jars;
78} nxt_java_app_conf_t;
79
80
81struct nxt_common_app_conf_s {
82 nxt_str_t name;
83 nxt_str_t type;
84 nxt_str_t user;
85 nxt_str_t group;
86
87 char *working_directory;
88 nxt_conf_value_t *environment;
89
90 nxt_conf_value_t *isolation;
91 nxt_conf_value_t *limits;
92
93 size_t shm_limit;
94
95 union {
96 nxt_external_app_conf_t external;
97 nxt_python_app_conf_t python;
98 nxt_php_app_conf_t php;
99 nxt_perl_app_conf_t perl;
100 nxt_ruby_app_conf_t ruby;
101 nxt_java_app_conf_t java;
102 } u;
103
104 nxt_conf_value_t *self;
105};
106
107
108struct nxt_app_module_s {
109 size_t compat_length;
110 uint32_t *compat;
111
112 nxt_str_t type;
113 const char *version;
114
115 const nxt_fs_mount_t *mounts;
116 nxt_uint_t nmounts;
117
118 nxt_application_setup_t setup;
119 nxt_process_start_t start;
120};
121
122
123nxt_app_lang_module_t *nxt_app_lang_module(nxt_runtime_t *rt, nxt_str_t *name);
124nxt_app_type_t nxt_app_parse_type(u_char *p, size_t length);
125
126NXT_EXPORT extern nxt_str_t nxt_server;
127extern nxt_app_module_t nxt_external_module;
128
129NXT_EXPORT nxt_int_t nxt_unit_default_init(nxt_task_t *task,
130 nxt_unit_init_t *init);
131
132
133#endif /* _NXT_APPLICATION_H_INCLIDED_ */
56} nxt_python_app_conf_t;
57
58
59typedef struct {
60 nxt_conf_value_t *targets;
61 nxt_conf_value_t *options;
62} nxt_php_app_conf_t;
63
64
65typedef struct {
66 char *script;
67} nxt_perl_app_conf_t;
68
69
70typedef struct {
71 nxt_str_t script;
72} nxt_ruby_app_conf_t;
73
74
75typedef struct {
76 nxt_conf_value_t *classpath;
77 char *webapp;
78 nxt_conf_value_t *options;
79 char *unit_jars;
80} nxt_java_app_conf_t;
81
82
83struct nxt_common_app_conf_s {
84 nxt_str_t name;
85 nxt_str_t type;
86 nxt_str_t user;
87 nxt_str_t group;
88
89 char *working_directory;
90 nxt_conf_value_t *environment;
91
92 nxt_conf_value_t *isolation;
93 nxt_conf_value_t *limits;
94
95 size_t shm_limit;
96
97 union {
98 nxt_external_app_conf_t external;
99 nxt_python_app_conf_t python;
100 nxt_php_app_conf_t php;
101 nxt_perl_app_conf_t perl;
102 nxt_ruby_app_conf_t ruby;
103 nxt_java_app_conf_t java;
104 } u;
105
106 nxt_conf_value_t *self;
107};
108
109
110struct nxt_app_module_s {
111 size_t compat_length;
112 uint32_t *compat;
113
114 nxt_str_t type;
115 const char *version;
116
117 const nxt_fs_mount_t *mounts;
118 nxt_uint_t nmounts;
119
120 nxt_application_setup_t setup;
121 nxt_process_start_t start;
122};
123
124
125nxt_app_lang_module_t *nxt_app_lang_module(nxt_runtime_t *rt, nxt_str_t *name);
126nxt_app_type_t nxt_app_parse_type(u_char *p, size_t length);
127
128NXT_EXPORT extern nxt_str_t nxt_server;
129extern nxt_app_module_t nxt_external_module;
130
131NXT_EXPORT nxt_int_t nxt_unit_default_init(nxt_task_t *task,
132 nxt_unit_init_t *init);
133
134
135#endif /* _NXT_APPLICATION_H_INCLIDED_ */