bitz-server  2.0.1
bitz-server.h
1 /*
2  * bitz-server, An ICAP server implementation in C++
3  * Copyright (C) 2012 Uditha Atukorala
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19 
20 #ifndef BITZ_SERVER_H
21 #define BITZ_SERVER_H
22 
23 #include "bitz/manager.h"
24 
25 #include <csignal>
26 #include <sys/types.h>
27 
28 
29 namespace bitz {
30 
31  namespace server {
32 
37  struct server_t {
38  pid_t pid;
39  int pidfd;
40  volatile sig_atomic_t terminating;
41  bool daemon;
42 
43  bitz::Manager * manager;
44  };
45 
49  struct options_t {
50  int debug_flag;
51  std::string config_file;
52  };
53 
54  void init();
55  void init_signal_handlers();
56  void init_sigchld_handler();
57  void init_sigterm_handler();
58  void init_sigquit_handler();
59  void init_sigint_handler();
60  void sigchld_handler( int sig, siginfo_t * sig_info, void * context );
61  void sigterm_handler( int sig, siginfo_t * sig_info, void * context );
62  void sigquit_handler( int sig, siginfo_t * sig_info, void * context );
63  void sigint_handler( int sig, siginfo_t * sig_info, void * context );
64 
65  void daemonize( const char * run_dir, const char * pid_file );
66  void shutdown();
67  void termination_handler( int sig, siginfo_t * sig_info, void * context );
68 
81  options_t read_options( int argc, char **argv );
82 
86  void print_version();
87 
91  void print_usage();
92 
102  void start( int port, unsigned int children, int max_requests, int comm_timeout );
103 
109  void run();
110 
111  } /* end of namespace server */
112 
113 } /* end of namespace bitz */
114 
115 #endif /* !BITZ_SERVER_H */
116 
Definition: echo.cpp:23
Definition: bitz-server.h:37
Definition: manager.h:41
Definition: bitz-server.h:49