blob: bfc1a351be99d6fddf8eba03bb2b1ec8aa88f0c4 [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 *
Willy Tarreaue9f49e72012-11-11 17:42:00 +01005 * Copyright (C) 2000-2012 Willy Tarreau - w@1wt.eu
Willy Tarreau8096de92010-02-26 11:12:27 +01006 *
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>
Willy Tarreauc7e42382012-08-24 19:22:53 +020028#include <types/freq_ctr.h>
Willy Tarreaud1d54542012-09-12 22:58:11 +020029#include <types/listener.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
Emeric Brunc8e8d122012-10-02 18:42:10 +020033#ifndef UNIX_MAX_PATH
34#define UNIX_MAX_PATH 108
35#endif
36
Willy Tarreaubaaee002006-06-26 02:48:02 +020037/* modes of operation (global.mode) */
Willy Tarreaufbee7132007-10-18 13:53:22 +020038#define MODE_DEBUG 0x01
39#define MODE_DAEMON 0x02
40#define MODE_QUIET 0x04
41#define MODE_CHECK 0x08
42#define MODE_VERBOSE 0x10
43#define MODE_STARTING 0x20
44#define MODE_FOREGROUND 0x40
Willy Tarreaubaaee002006-06-26 02:48:02 +020045
Willy Tarreau77074d52006-11-12 23:57:19 +010046/* list of last checks to perform, depending on config options */
47#define LSTCHK_CAP_BIND 0x00000001 /* check that we can bind to any port */
48#define LSTCHK_CTTPROXY 0x00000002 /* check that tproxy is enabled */
49#define LSTCHK_NETADM 0x00000004 /* check that we have CAP_NET_ADMIN */
Willy Tarreaubaaee002006-06-26 02:48:02 +020050
Willy Tarreau43b78992009-01-25 15:42:27 +010051/* Global tuning options */
52/* available polling mechanisms */
53#define GTUNE_USE_SELECT (1<<0)
54#define GTUNE_USE_POLL (1<<1)
55#define GTUNE_USE_EPOLL (1<<2)
56#define GTUNE_USE_KQUEUE (1<<3)
Willy Tarreau3ab68cf2009-01-25 16:03:28 +010057/* platform-specific options */
Willy Tarreaue9f49e72012-11-11 17:42:00 +010058#define GTUNE_USE_SPLICE (1<<4)
Willy Tarreau43b78992009-01-25 15:42:27 +010059
Willy Tarreau6162db22009-10-10 17:13:00 +020060/* Access level for a stats socket */
61#define ACCESS_LVL_NONE 0
62#define ACCESS_LVL_USER 1
63#define ACCESS_LVL_OPER 2
64#define ACCESS_LVL_ADMIN 3
Willy Tarreau43b78992009-01-25 15:42:27 +010065
Willy Tarreaubaaee002006-06-26 02:48:02 +020066/* FIXME : this will have to be redefined correctly */
67struct global {
Emeric Brunc8e8d122012-10-02 18:42:10 +020068#ifdef USE_OPENSSL
69 char *crt_base; /* base directory path for certificates */
70 char *ca_base; /* base directory path for CAs and CRLs */
71#endif
Willy Tarreau77074d52006-11-12 23:57:19 +010072 int uid;
73 int gid;
74 int nbproc;
Willy Tarreau91886b62011-09-07 14:38:31 +020075 int maxconn, hardmaxconn;
Willy Tarreau403edff2012-09-06 11:58:37 +020076#ifdef USE_OPENSSL
77 int maxsslconn;
Emeric Brun76d88952012-10-05 15:47:31 +020078 char *listen_default_ciphers;
79 char *connect_default_ciphers;
Willy Tarreau403edff2012-09-06 11:58:37 +020080#endif
Willy Tarreau81c25d02011-09-07 15:17:21 +020081 struct freq_ctr conn_per_sec;
William Lallemandd85f9172012-11-09 17:05:39 +010082 struct freq_ctr comp_bps_in; /* bytes per second, before http compression */
83 struct freq_ctr comp_bps_out; /* bytes per second, after http compression */
Willy Tarreau81c25d02011-09-07 15:17:21 +020084 int cps_lim, cps_max;
William Lallemandd85f9172012-11-09 17:05:39 +010085 int comp_rate_lim; /* HTTP compression rate limit */
Willy Tarreau3ec79b92009-01-18 20:39:42 +010086 int maxpipes; /* max # of pipes */
Willy Tarreau77074d52006-11-12 23:57:19 +010087 int maxsock; /* max # of sockets */
88 int rlimit_nofile; /* default ulimit-n value : 0=unset */
89 int rlimit_memmax; /* default ulimit-d in megs value : 0=unset */
William Lallemande3a7d992012-11-20 11:25:20 +010090 long maxzlibmem; /* max RAM for zlib in bytes */
Willy Tarreau77074d52006-11-12 23:57:19 +010091 int mode;
William Lallemand5f232402012-04-05 18:02:55 +020092 unsigned int req_count; /* HTTP request counter */
Willy Tarreau77074d52006-11-12 23:57:19 +010093 int last_checks;
Krzysztof Oledzkib304dc72007-10-14 23:40:01 +020094 int spread_checks;
Willy Tarreau77074d52006-11-12 23:57:19 +010095 char *chroot;
96 char *pidfile;
Krzysztof Piotr Oledzki48cb2ae2009-10-02 22:51:14 +020097 char *node, *desc; /* node name & description */
Kevinm48936af2010-12-22 16:08:21 +000098 char *log_tag; /* name for syslog */
William Lallemand0f99e342011-10-12 17:50:54 +020099 struct list logsrvs;
Joe Williamsdf5b38f2010-12-29 17:05:48 +0100100 char *log_send_hostname; /* set hostname in syslog header */
Willy Tarreau1db37712007-06-03 17:16:49 +0200101 struct {
102 int maxpollevents; /* max number of poll events at once */
Willy Tarreaua0250ba2008-01-06 11:22:57 +0100103 int maxaccept; /* max number of consecutive accept() */
Willy Tarreau43b78992009-01-25 15:42:27 +0100104 int options; /* various tuning options */
Willy Tarreau6f4a82c2009-03-21 20:43:57 +0100105 int recv_enough; /* how many input bytes at once are "enough" */
Willy Tarreau27a674e2009-08-17 07:23:33 +0200106 int bufsize; /* buffer size in bytes, defaults to BUFSIZE */
107 int maxrewrite; /* buffer max rewrite size in bytes, defaults to MAXREWRITE */
Willy Tarreaue803de22010-01-21 17:43:04 +0100108 int client_sndbuf; /* set client sndbuf to this value if not null */
109 int client_rcvbuf; /* set client rcvbuf to this value if not null */
110 int server_sndbuf; /* set server sndbuf to this value if not null */
111 int server_rcvbuf; /* set server rcvbuf to this value if not null */
Willy Tarreau43961d52010-10-04 20:39:20 +0200112 int chksize; /* check buffer size in bytes, defaults to BUFSIZE */
Willy Tarreaubd9a0a72011-10-23 21:14:29 +0200113 int pipesize; /* pipe size in bytes, system defaults if zero */
Willy Tarreauac1932d2011-10-24 19:14:41 +0200114 int max_http_hdr; /* max number of HTTP headers, use MAX_HTTP_HDR if zero */
Willy Tarreau193b8c62012-11-22 00:17:38 +0100115 int cookie_len; /* max length of cookie captures */
Emeric Brunfc32aca2012-09-03 12:10:29 +0200116#ifdef USE_OPENSSL
117 int sslcachesize; /* SSL cache size in session, defaults to 20000 */
Emeric Brun4f65bff2012-11-16 15:11:00 +0100118 unsigned int ssllifetime; /* SSL session lifetime in seconds */
Emeric Brunfc32aca2012-09-03 12:10:29 +0200119#endif
William Lallemanda509e4c2012-11-07 16:54:34 +0100120#ifdef USE_ZLIB
121 int zlibmemlevel; /* zlib memlevel */
122 int zlibwindowsize; /* zlib window size */
123#endif
William Lallemandf3747832012-11-09 12:33:10 +0100124 int comp_maxlevel; /* max HTTP compression level */
Willy Tarreau1db37712007-06-03 17:16:49 +0200125 } tune;
Emeric Bruned760922010-10-22 17:59:25 +0200126 struct {
127 char *prefix; /* path prefix of unix bind socket */
128 struct { /* UNIX socket permissions */
129 uid_t uid; /* -1 to leave unchanged */
130 gid_t gid; /* -1 to leave unchanged */
131 mode_t mode; /* 0 to leave unchanged */
132 int level; /* access level (ACCESS_LVL_*) */
133 } ux;
134 } unix_bind;
Willy Tarreaufc6c0322012-11-16 16:12:27 +0100135#ifdef USE_CPU_AFFINITY
136 unsigned long cpu_map[32]; /* list of CPU masks for the 32 first processes */
137#endif
Willy Tarreau89a63132009-08-16 17:41:45 +0200138 struct proxy *stats_fe; /* the frontend holding the stats settings */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200139};
140
141extern struct global global;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200142extern int pid; /* current process id */
Willy Tarreaudcd47712007-11-04 23:35:08 +0100143extern int relative_pid; /* process id starting at 1 */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200144extern int actconn; /* # of active sessions */
Willy Tarreauaf7ad002010-08-31 15:39:26 +0200145extern int listeners;
146extern int jobs; /* # of active jobs */
Willy Tarreau19d14ef2012-10-29 16:51:55 +0100147extern struct chunk trash;
Willy Tarreau8096de92010-02-26 11:12:27 +0100148extern char *swap_buffer;
Willy Tarreaubb545b42010-08-25 12:58:59 +0200149extern int nb_oldpids; /* contains the number of old pids found */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200150extern const int zero;
151extern const int one;
Alexandre Cassen87ea5482007-10-11 20:48:58 +0200152extern const struct linger nolinger;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200153extern int stopping; /* non zero means stopping in progress */
Willy Tarreau3ad6a762009-08-16 10:08:02 +0200154extern char hostname[MAX_HOSTNAME_LEN];
Emeric Brun2b920a12010-09-23 18:30:22 +0200155extern char localpeer[MAX_HOSTNAME_LEN];
Willy Tarreau08ceb102011-07-24 22:58:00 +0200156extern struct list global_listener_queue; /* list of the temporarily limited listeners */
Willy Tarreaue9b26022011-08-01 20:57:55 +0200157extern struct task *global_listener_queue_task;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200158
159#endif /* _TYPES_GLOBAL_H */
160
161/*
162 * Local variables:
163 * c-indent-level: 8
164 * c-basic-offset: 8
165 * End:
166 */