blob: 4469ef86ba7ef20a31541fc7185ddf7aacaa20f7 [file] [log] [blame]
Willy Tarreaubaaee002006-06-26 02:48:02 +02001/*
Willy Tarreau8096de92010-02-26 11:12:27 +01002 * include/types/global.h
3 * Global variables.
4 *
5 * Copyright (C) 2000-2010 Willy Tarreau - w@1wt.eu
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation, version 2.1
10 * exclusively.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
Willy Tarreaubaaee002006-06-26 02:48:02 +020021
22#ifndef _TYPES_GLOBAL_H
23#define _TYPES_GLOBAL_H
24
25#include <netinet/in.h>
26
Willy Tarreaue3ba5f02006-06-29 18:54:54 +020027#include <common/config.h>
Robert Tsai81ae1952007-12-05 10:47:29 +010028#include <types/log.h>
Willy Tarreau92fb9832007-10-16 17:34:28 +020029#include <types/protocols.h>
Willy Tarreau89a63132009-08-16 17:41:45 +020030#include <types/proxy.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020031#include <types/task.h>
32
33/* modes of operation (global.mode) */
Willy Tarreaufbee7132007-10-18 13:53:22 +020034#define MODE_DEBUG 0x01
35#define MODE_DAEMON 0x02
36#define MODE_QUIET 0x04
37#define MODE_CHECK 0x08
38#define MODE_VERBOSE 0x10
39#define MODE_STARTING 0x20
40#define MODE_FOREGROUND 0x40
Willy Tarreaubaaee002006-06-26 02:48:02 +020041
Willy Tarreau77074d52006-11-12 23:57:19 +010042/* list of last checks to perform, depending on config options */
43#define LSTCHK_CAP_BIND 0x00000001 /* check that we can bind to any port */
44#define LSTCHK_CTTPROXY 0x00000002 /* check that tproxy is enabled */
45#define LSTCHK_NETADM 0x00000004 /* check that we have CAP_NET_ADMIN */
Willy Tarreaubaaee002006-06-26 02:48:02 +020046
Willy Tarreau43b78992009-01-25 15:42:27 +010047/* Global tuning options */
48/* available polling mechanisms */
49#define GTUNE_USE_SELECT (1<<0)
50#define GTUNE_USE_POLL (1<<1)
51#define GTUNE_USE_EPOLL (1<<2)
52#define GTUNE_USE_KQUEUE (1<<3)
53#define GTUNE_USE_SEPOLL (1<<4)
Willy Tarreau3ab68cf2009-01-25 16:03:28 +010054/* platform-specific options */
55#define GTUNE_USE_SPLICE (1<<5)
Willy Tarreau43b78992009-01-25 15:42:27 +010056
Willy Tarreau6162db22009-10-10 17:13:00 +020057/* Access level for a stats socket */
58#define ACCESS_LVL_NONE 0
59#define ACCESS_LVL_USER 1
60#define ACCESS_LVL_OPER 2
61#define ACCESS_LVL_ADMIN 3
Willy Tarreau43b78992009-01-25 15:42:27 +010062
Willy Tarreaubaaee002006-06-26 02:48:02 +020063/* FIXME : this will have to be redefined correctly */
64struct global {
Willy Tarreau77074d52006-11-12 23:57:19 +010065 int uid;
66 int gid;
67 int nbproc;
68 int maxconn;
Willy Tarreau3ec79b92009-01-18 20:39:42 +010069 int maxpipes; /* max # of pipes */
Willy Tarreau77074d52006-11-12 23:57:19 +010070 int maxsock; /* max # of sockets */
71 int rlimit_nofile; /* default ulimit-n value : 0=unset */
72 int rlimit_memmax; /* default ulimit-d in megs value : 0=unset */
73 int mode;
74 int last_checks;
Krzysztof Oledzkib304dc72007-10-14 23:40:01 +020075 int spread_checks;
Willy Tarreau77074d52006-11-12 23:57:19 +010076 char *chroot;
77 char *pidfile;
Krzysztof Piotr Oledzki48cb2ae2009-10-02 22:51:14 +020078 char *node, *desc; /* node name & description */
Willy Tarreau77074d52006-11-12 23:57:19 +010079 int logfac1, logfac2;
80 int loglev1, loglev2;
Willy Tarreauf7edefa2009-05-10 17:20:05 +020081 int minlvl1, minlvl2;
Robert Tsai81ae1952007-12-05 10:47:29 +010082 struct logsrv logsrv1, logsrv2;
Willy Tarreau1db37712007-06-03 17:16:49 +020083 struct {
84 int maxpollevents; /* max number of poll events at once */
Willy Tarreaua0250ba2008-01-06 11:22:57 +010085 int maxaccept; /* max number of consecutive accept() */
Willy Tarreau43b78992009-01-25 15:42:27 +010086 int options; /* various tuning options */
Willy Tarreau6f4a82c2009-03-21 20:43:57 +010087 int recv_enough; /* how many input bytes at once are "enough" */
Willy Tarreau27a674e2009-08-17 07:23:33 +020088 int bufsize; /* buffer size in bytes, defaults to BUFSIZE */
89 int maxrewrite; /* buffer max rewrite size in bytes, defaults to MAXREWRITE */
Willy Tarreaue803de22010-01-21 17:43:04 +010090 int client_sndbuf; /* set client sndbuf to this value if not null */
91 int client_rcvbuf; /* set client rcvbuf to this value if not null */
92 int server_sndbuf; /* set server sndbuf to this value if not null */
93 int server_rcvbuf; /* set server rcvbuf to this value if not null */
Willy Tarreau43961d52010-10-04 20:39:20 +020094 int chksize; /* check buffer size in bytes, defaults to BUFSIZE */
Willy Tarreau1db37712007-06-03 17:16:49 +020095 } tune;
Willy Tarreau92fb9832007-10-16 17:34:28 +020096 struct listener stats_sock; /* unix socket listener for statistics */
Willy Tarreau89a63132009-08-16 17:41:45 +020097 struct proxy *stats_fe; /* the frontend holding the stats settings */
Willy Tarreaubaaee002006-06-26 02:48:02 +020098};
99
100extern struct global global;
101extern char *progname; /* program name */
102extern int pid; /* current process id */
Willy Tarreaudcd47712007-11-04 23:35:08 +0100103extern int relative_pid; /* process id starting at 1 */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200104extern int actconn; /* # of active sessions */
Willy Tarreauaf7ad002010-08-31 15:39:26 +0200105extern int listeners;
106extern int jobs; /* # of active jobs */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200107extern char trash[BUFSIZE];
Willy Tarreau8096de92010-02-26 11:12:27 +0100108extern char *swap_buffer;
Willy Tarreaubb545b42010-08-25 12:58:59 +0200109extern int nb_oldpids; /* contains the number of old pids found */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200110extern const int zero;
111extern const int one;
Alexandre Cassen87ea5482007-10-11 20:48:58 +0200112extern const struct linger nolinger;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200113extern int stopping; /* non zero means stopping in progress */
Willy Tarreau3ad6a762009-08-16 10:08:02 +0200114extern char hostname[MAX_HOSTNAME_LEN];
Willy Tarreaubaaee002006-06-26 02:48:02 +0200115
116#endif /* _TYPES_GLOBAL_H */
117
118/*
119 * Local variables:
120 * c-indent-level: 8
121 * c-basic-offset: 8
122 * End:
123 */