xref: /unit/src/nxt_application.h (revision 1182:325b315e48c4)
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 
31 
32 typedef struct {
33     nxt_app_type_t            type;
34     u_char                    *version;
35     char                      *file;
36     nxt_app_module_t          *module;
37 } nxt_app_lang_module_t;
38 
39 
40 typedef struct nxt_common_app_conf_s nxt_common_app_conf_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_str_t  path;
52     nxt_str_t  module;
53 } nxt_python_app_conf_t;
54 
55 
56 typedef struct {
57     char                       *root;
58     nxt_str_t                  script;
59     nxt_str_t                  index;
60     nxt_conf_value_t           *options;
61 } nxt_php_app_conf_t;
62 
63 
64 typedef struct {
65     char       *script;
66 } nxt_perl_app_conf_t;
67 
68 
69 typedef struct {
70     nxt_str_t  script;
71 } nxt_ruby_app_conf_t;
72 
73 
74 typedef struct {
75     nxt_conf_value_t           *classpath;
76     char                       *webapp;
77     nxt_conf_value_t           *options;
78     char                       *unit_jars;
79 } nxt_java_app_conf_t;
80 
81 
82 struct nxt_common_app_conf_s {
83     nxt_str_t                  name;
84     nxt_str_t                  type;
85     nxt_str_t                  user;
86     nxt_str_t                  group;
87 
88     char                       *working_directory;
89     nxt_conf_value_t           *environment;
90 
91     nxt_conf_value_t           *isolation;
92 
93     union {
94         nxt_external_app_conf_t  external;
95         nxt_python_app_conf_t    python;
96         nxt_php_app_conf_t       php;
97         nxt_perl_app_conf_t      perl;
98         nxt_ruby_app_conf_t      ruby;
99         nxt_java_app_conf_t      java;
100     } u;
101 };
102 
103 
104 struct nxt_app_module_s {
105     size_t                     compat_length;
106     uint32_t                   *compat;
107 
108     nxt_str_t                  type;
109     const char                 *version;
110 
111     nxt_int_t                  (*pre_init)(nxt_task_t *task,
112                                     nxt_common_app_conf_t *conf);
113     nxt_int_t                  (*init)(nxt_task_t *task,
114                                     nxt_common_app_conf_t *conf);
115 };
116 
117 
118 nxt_app_lang_module_t *nxt_app_lang_module(nxt_runtime_t *rt, nxt_str_t *name);
119 nxt_app_type_t nxt_app_parse_type(u_char *p, size_t length);
120 
121 NXT_EXPORT extern nxt_str_t  nxt_server;
122 extern nxt_app_module_t      nxt_external_module;
123 
124 NXT_EXPORT nxt_int_t nxt_unit_default_init(nxt_task_t *task,
125     nxt_unit_init_t *init);
126 
127 
128 #endif /* _NXT_APPLICATION_H_INCLIDED_ */
129