xref: /unit/src/nxt_runtime.h (revision 1998:c8790d2a89bb)
120Sigor@sysoev.ru 
220Sigor@sysoev.ru /*
320Sigor@sysoev.ru  * Copyright (C) Igor Sysoev
420Sigor@sysoev.ru  * Copyright (C) Valentin V. Bartenev
520Sigor@sysoev.ru  * Copyright (C) NGINX, Inc.
620Sigor@sysoev.ru  */
720Sigor@sysoev.ru 
820Sigor@sysoev.ru #ifndef _NXT_RUNTIME_H_INCLUDED_
920Sigor@sysoev.ru #define _NXT_RUNTIME_H_INCLUDED_
1020Sigor@sysoev.ru 
1120Sigor@sysoev.ru 
12697Sigor@sysoev.ru typedef void (*nxt_runtime_cont_t)(nxt_task_t *task, nxt_uint_t status);
1320Sigor@sysoev.ru 
1420Sigor@sysoev.ru 
1520Sigor@sysoev.ru struct nxt_runtime_s {
1665Sigor@sysoev.ru     nxt_mp_t               *mem_pool;
1720Sigor@sysoev.ru 
1820Sigor@sysoev.ru     nxt_array_t            *inherited_sockets;  /* of nxt_listen_socket_t */
1920Sigor@sysoev.ru     nxt_array_t            *listen_sockets;     /* of nxt_listen_socket_t */
2020Sigor@sysoev.ru 
2120Sigor@sysoev.ru     nxt_array_t            *services;           /* of nxt_service_t */
22216Sigor@sysoev.ru     nxt_array_t            *languages;          /* of nxt_app_lang_module_t */
2353Sigor@sysoev.ru     void                   *data;
2420Sigor@sysoev.ru 
2520Sigor@sysoev.ru     nxt_runtime_cont_t     start;
2620Sigor@sysoev.ru 
2720Sigor@sysoev.ru     nxt_str_t              hostname;
2820Sigor@sysoev.ru 
2920Sigor@sysoev.ru     nxt_file_name_t        *pid_file;
3020Sigor@sysoev.ru 
31771Sigor@sysoev.ru #if (NXT_TLS)
32771Sigor@sysoev.ru     const nxt_tls_lib_t    *tls;
33771Sigor@sysoev.ru #endif
34771Sigor@sysoev.ru 
3520Sigor@sysoev.ru     nxt_array_t            *thread_pools;       /* of nxt_thread_pool_t */
3620Sigor@sysoev.ru     nxt_runtime_cont_t     continuation;
3720Sigor@sysoev.ru 
3842Smax.romanov@nginx.com     nxt_process_t          *mprocess;
3942Smax.romanov@nginx.com     size_t                 nprocesses;
40196Smax.romanov@nginx.com     nxt_thread_mutex_t     processes_mutex;
4142Smax.romanov@nginx.com     nxt_lvlhsh_t           processes;           /* of nxt_process_t */
4242Smax.romanov@nginx.com 
43141Smax.romanov@nginx.com     nxt_port_t             *port_by_type[NXT_PROCESS_MAX];
4442Smax.romanov@nginx.com     nxt_lvlhsh_t           ports;               /* of nxt_port_t */
4520Sigor@sysoev.ru 
4620Sigor@sysoev.ru     nxt_list_t             *log_files;          /* of nxt_file_t */
4720Sigor@sysoev.ru 
4820Sigor@sysoev.ru     uint32_t               last_engine_id;
4920Sigor@sysoev.ru 
50696Sigor@sysoev.ru     nxt_process_type_t     type;
5120Sigor@sysoev.ru 
5220Sigor@sysoev.ru     nxt_timer_t            timer;
5320Sigor@sysoev.ru 
5420Sigor@sysoev.ru     uint8_t                daemon;
5520Sigor@sysoev.ru     uint8_t                batch;
56697Sigor@sysoev.ru     uint8_t                status;
57*1998St.nateldemoura@f5.com     uint8_t                is_pid_isolated;
58697Sigor@sysoev.ru 
5920Sigor@sysoev.ru     const char             *engine;
6020Sigor@sysoev.ru     uint32_t               engine_connections;
6120Sigor@sysoev.ru     uint32_t               auxiliary_threads;
621305St.nateldemoura@f5.com     nxt_credential_t       user_cred;
631182St.nateldemoura@f5.com     nxt_capabilities_t     capabilities;
6420Sigor@sysoev.ru     const char             *group;
6520Sigor@sysoev.ru     const char             *pid;
66230Sigor@sysoev.ru     const char             *log;
67233Sigor@sysoev.ru     const char             *modules;
68314Svbart@nginx.com     const char             *state;
691969Sz.hong@f5.com     const char             *ver;
701969Sz.hong@f5.com     const char             *ver_tmp;
71314Svbart@nginx.com     const char             *conf;
72314Svbart@nginx.com     const char             *conf_tmp;
73234Sigor@sysoev.ru     const char             *control;
741403Smax.romanov@nginx.com     const char             *tmp;
7520Sigor@sysoev.ru 
76774Svbart@nginx.com     nxt_str_t              certs;
77774Svbart@nginx.com 
7853Sigor@sysoev.ru     nxt_queue_t            engines;            /* of nxt_event_engine_t */
7953Sigor@sysoev.ru 
8020Sigor@sysoev.ru     nxt_sockaddr_t         *controller_listen;
8120Sigor@sysoev.ru     nxt_listen_socket_t    *controller_socket;
8220Sigor@sysoev.ru };
8320Sigor@sysoev.ru 
8420Sigor@sysoev.ru 
8520Sigor@sysoev.ru 
8620Sigor@sysoev.ru typedef nxt_int_t (*nxt_module_init_t)(nxt_thread_t *thr, nxt_runtime_t *rt);
8720Sigor@sysoev.ru 
8820Sigor@sysoev.ru 
8920Sigor@sysoev.ru nxt_int_t nxt_runtime_create(nxt_task_t *task);
90697Sigor@sysoev.ru void nxt_runtime_quit(nxt_task_t *task, nxt_uint_t status);
9120Sigor@sysoev.ru 
9220Sigor@sysoev.ru void nxt_runtime_event_engine_free(nxt_runtime_t *rt);
9320Sigor@sysoev.ru 
9420Sigor@sysoev.ru nxt_int_t nxt_runtime_thread_pool_create(nxt_thread_t *thr, nxt_runtime_t *rt,
9520Sigor@sysoev.ru     nxt_uint_t max_threads, nxt_nsec_t timeout);
9620Sigor@sysoev.ru 
9720Sigor@sysoev.ru 
98343Smax.romanov@nginx.com void nxt_runtime_process_add(nxt_task_t *task, nxt_process_t *process);
99*1998St.nateldemoura@f5.com void nxt_runtime_process_remove(nxt_runtime_t *rt, nxt_process_t *process);
10042Smax.romanov@nginx.com 
10142Smax.romanov@nginx.com nxt_process_t *nxt_runtime_process_find(nxt_runtime_t *rt, nxt_pid_t pid);
10242Smax.romanov@nginx.com 
10342Smax.romanov@nginx.com nxt_process_t *nxt_runtime_process_first(nxt_runtime_t *rt,
10442Smax.romanov@nginx.com     nxt_lvlhsh_each_t *lhe);
10542Smax.romanov@nginx.com 
1061254Shongzhidao@gmail.com void nxt_runtime_process_release(nxt_runtime_t *rt, nxt_process_t *process);
1071254Shongzhidao@gmail.com 
10842Smax.romanov@nginx.com #define nxt_runtime_process_next(rt, lhe)                                     \
10942Smax.romanov@nginx.com     nxt_lvlhsh_each(&rt->processes, lhe)
11042Smax.romanov@nginx.com 
1111254Shongzhidao@gmail.com nxt_port_t *nxt_runtime_process_port_create(nxt_task_t *task, nxt_runtime_t *rt,
1121254Shongzhidao@gmail.com     nxt_pid_t pid, nxt_port_id_t id, nxt_process_type_t type);
11342Smax.romanov@nginx.com 
114343Smax.romanov@nginx.com void nxt_runtime_port_remove(nxt_task_t *task, nxt_port_t *port);
1151488St.nateldemoura@f5.com void nxt_runtime_stop_app_processes(nxt_task_t *task, nxt_runtime_t *rt);
11642Smax.romanov@nginx.com 
117743Smax.romanov@nginx.com NXT_EXPORT nxt_port_t *nxt_runtime_port_find(nxt_runtime_t *rt, nxt_pid_t pid,
11842Smax.romanov@nginx.com     nxt_port_id_t port_id);
11942Smax.romanov@nginx.com 
12020Sigor@sysoev.ru 
12120Sigor@sysoev.ru /* STUB */
12220Sigor@sysoev.ru nxt_int_t nxt_runtime_controller_socket(nxt_task_t *task, nxt_runtime_t *rt);
12320Sigor@sysoev.ru 
12465Sigor@sysoev.ru nxt_str_t *nxt_current_directory(nxt_mp_t *mp);
12520Sigor@sysoev.ru 
12620Sigor@sysoev.ru nxt_listen_socket_t *nxt_runtime_listen_socket_add(nxt_runtime_t *rt,
12720Sigor@sysoev.ru     nxt_sockaddr_t *sa);
12820Sigor@sysoev.ru nxt_int_t nxt_runtime_listen_sockets_create(nxt_task_t *task,
12920Sigor@sysoev.ru     nxt_runtime_t *rt);
13020Sigor@sysoev.ru nxt_int_t nxt_runtime_listen_sockets_enable(nxt_task_t *task,
13120Sigor@sysoev.ru     nxt_runtime_t *rt);
13220Sigor@sysoev.ru nxt_file_t *nxt_runtime_log_file_add(nxt_runtime_t *rt, nxt_str_t *name);
13320Sigor@sysoev.ru 
13420Sigor@sysoev.ru /* STUB */
13520Sigor@sysoev.ru void nxt_cdecl nxt_log_time_handler(nxt_uint_t level, nxt_log_t *log,
13620Sigor@sysoev.ru     const char *fmt, ...);
13720Sigor@sysoev.ru 
13820Sigor@sysoev.ru void nxt_stream_connection_init(nxt_task_t *task, void *obj, void *data);
13920Sigor@sysoev.ru 
1401563Svbart@nginx.com nxt_int_t nxt_http_register_variables(void);
1411563Svbart@nginx.com 
14220Sigor@sysoev.ru 
14342Smax.romanov@nginx.com #define nxt_runtime_process_each(rt, process)                                 \
14442Smax.romanov@nginx.com     do {                                                                      \
14542Smax.romanov@nginx.com         nxt_lvlhsh_each_t  _lhe;                                              \
146125Smax.romanov@nginx.com         nxt_process_t      *_nxt;                                             \
14742Smax.romanov@nginx.com                                                                               \
14842Smax.romanov@nginx.com         for (process = nxt_runtime_process_first(rt, &_lhe);                  \
14942Smax.romanov@nginx.com              process != NULL;                                                 \
150125Smax.romanov@nginx.com              process = _nxt) {                                                \
151125Smax.romanov@nginx.com                                                                               \
152125Smax.romanov@nginx.com             _nxt = nxt_runtime_process_next(rt, &_lhe);                       \
15342Smax.romanov@nginx.com 
15442Smax.romanov@nginx.com #define nxt_runtime_process_loop                                              \
15542Smax.romanov@nginx.com         }                                                                     \
15642Smax.romanov@nginx.com     } while(0)
15742Smax.romanov@nginx.com 
15842Smax.romanov@nginx.com 
15920Sigor@sysoev.ru extern nxt_module_init_t  nxt_init_modules[];
16020Sigor@sysoev.ru extern nxt_uint_t         nxt_init_modules_n;
16120Sigor@sysoev.ru 
16220Sigor@sysoev.ru 
16320Sigor@sysoev.ru #endif /* _NXT_RUNTIME_H_INCLIDED_ */
164