xref: /unit/src/nxt_application.h (revision 1488:6976d36be926)
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_app_lang_module_t;
40 
41 
42 typedef struct {
43     char                       *executable;
44     nxt_conf_value_t           *arguments;
45 } nxt_external_app_conf_t;
46 
47 
48 typedef struct {
49     char       *home;
50     nxt_str_t  path;
51     nxt_str_t  module;
52 } nxt_python_app_conf_t;
53 
54 
55 typedef struct {
56     nxt_conf_value_t           *targets;
57     nxt_conf_value_t           *options;
58 } nxt_php_app_conf_t;
59 
60 
61 typedef struct {
62     char       *script;
63 } nxt_perl_app_conf_t;
64 
65 
66 typedef struct {
67     nxt_str_t  script;
68 } nxt_ruby_app_conf_t;
69 
70 
71 typedef struct {
72     nxt_conf_value_t           *classpath;
73     char                       *webapp;
74     nxt_conf_value_t           *options;
75     char                       *unit_jars;
76 } nxt_java_app_conf_t;
77 
78 
79 struct nxt_common_app_conf_s {
80     nxt_str_t                  name;
81     nxt_str_t                  type;
82     nxt_str_t                  user;
83     nxt_str_t                  group;
84 
85     char                       *working_directory;
86     nxt_conf_value_t           *environment;
87 
88     nxt_conf_value_t           *isolation;
89     nxt_conf_value_t           *limits;
90 
91     size_t                     shm_limit;
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     nxt_conf_value_t           *self;
103 };
104 
105 
106 struct nxt_app_module_s {
107     size_t                     compat_length;
108     uint32_t                   *compat;
109 
110     nxt_str_t                  type;
111     const char                 *version;
112 
113     nxt_application_setup_t    setup;
114     nxt_process_start_t        start;
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