xref: /unit/src/nxt_application.h (revision 2240:0c49318572c2)
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 
17 typedef 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 
29 typedef struct nxt_app_module_s  nxt_app_module_t;
30 typedef nxt_int_t (*nxt_application_setup_t)(nxt_task_t *task,
31     nxt_process_t *process, nxt_common_app_conf_t *conf);
32 
33 
34 typedef 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 
43 typedef struct {
44     char                       *executable;
45     nxt_conf_value_t           *arguments;
46 } nxt_external_app_conf_t;
47 
48 
49 typedef struct {
50     char                       *home;
51     nxt_conf_value_t           *path;
52     char                       *callable;
53     nxt_str_t                  protocol;
54     uint32_t                   threads;
55     uint32_t                   thread_stack_size;
56     nxt_conf_value_t           *targets;
57 } nxt_python_app_conf_t;
58 
59 
60 typedef struct {
61     nxt_conf_value_t           *targets;
62     nxt_conf_value_t           *options;
63 } nxt_php_app_conf_t;
64 
65 
66 typedef struct {
67     char       *script;
68     uint32_t   threads;
69     uint32_t   thread_stack_size;
70 } nxt_perl_app_conf_t;
71 
72 
73 typedef struct {
74     nxt_str_t  script;
75     uint32_t   threads;
76     nxt_str_t  hooks;
77 } nxt_ruby_app_conf_t;
78 
79 
80 typedef struct {
81     nxt_conf_value_t           *classpath;
82     char                       *webapp;
83     nxt_conf_value_t           *options;
84     char                       *unit_jars;
85     uint32_t                   threads;
86     uint32_t                   thread_stack_size;
87 } nxt_java_app_conf_t;
88 
89 
90 struct nxt_common_app_conf_s {
91     nxt_str_t                  name;
92     nxt_str_t                  type;
93     nxt_str_t                  user;
94     nxt_str_t                  group;
95 
96     char                       *working_directory;
97     nxt_conf_value_t           *environment;
98 
99     nxt_conf_value_t           *isolation;
100     nxt_conf_value_t           *limits;
101 
102     size_t                     shm_limit;
103     uint32_t                   request_limit;
104 
105     nxt_fd_t                   shared_port_fd;
106     nxt_fd_t                   shared_queue_fd;
107 
108     union {
109         nxt_external_app_conf_t  external;
110         nxt_python_app_conf_t    python;
111         nxt_php_app_conf_t       php;
112         nxt_perl_app_conf_t      perl;
113         nxt_ruby_app_conf_t      ruby;
114         nxt_java_app_conf_t      java;
115     } u;
116 
117     nxt_conf_value_t           *self;
118 };
119 
120 
121 struct nxt_app_module_s {
122     size_t                     compat_length;
123     uint32_t                   *compat;
124 
125     nxt_str_t                  type;
126     const char                 *version;
127 
128     const nxt_fs_mount_t       *mounts;
129     nxt_uint_t                 nmounts;
130 
131     nxt_application_setup_t    setup;
132     nxt_process_start_t        start;
133 };
134 
135 
136 nxt_app_lang_module_t *nxt_app_lang_module(nxt_runtime_t *rt, nxt_str_t *name);
137 nxt_app_type_t nxt_app_parse_type(u_char *p, size_t length);
138 
139 NXT_EXPORT extern nxt_str_t  nxt_server;
140 extern nxt_app_module_t      nxt_external_module;
141 
142 NXT_EXPORT nxt_int_t nxt_unit_default_init(nxt_task_t *task,
143     nxt_unit_init_t *init, nxt_common_app_conf_t *conf);
144 
145 
146 #endif /* _NXT_APPLICATION_H_INCLIDED_ */
147