OPeNDAP Hyrax Back End Server (BES)
Updated for version 3.8.3
|
#include <unistd.h>
#include <grp.h>
#include <pwd.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
#include <signal.h>
#include <fstream>
#include <iostream>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <cerrno>
#include "config.h"
#include "ServerExitConditions.h"
#include "SocketListener.h"
#include "TcpSocket.h"
#include "UnixSocket.h"
#include "PPTServer.h"
#include "BESModuleApp.h"
#include "DaemonCommandHandler.h"
#include "BESServerUtils.h"
#include "BESScrub.h"
#include "BESError.h"
#include "BESDebug.h"
#include "TheBESKeys.h"
#include "BESLog.h"
#include "BESDaemonConstants.h"
Go to the source code of this file.
Macros | |
#define | BES_SERVER "/beslistener" |
#define | BES_SERVER_PID "/bes.pid" |
#define | DAEMON_PORT_STR "BES.DaemonPort" |
#define | DAEMON_UNIX_SOCK_STR "BES.DaemonUnixSocket" |
Typedefs | |
typedef map< string, string > | arg_map |
Functions | |
void | block_signals () |
For code that must use signals to stop and start the master listener, block signals being delivered to this process. More... | |
int | main (int argc, char *argv[]) |
Run the daemon. More... | |
int | start_master_beslistener () |
Start the 'master beslistener' and return its PID. More... | |
bool | stop_all_beslisteners (int sig) |
Stop all of the listeners (both the master listener and all of the child listeners that actually process requests). More... | |
void | unblock_signals () |
See block_signals() More... | |
char ** | update_beslistener_args () |
Update the arguments passed to the master beslistener so that changes in the debug/log contexts set in the besdaemon will also be set in the beslisteners. More... | |
Variables | |
volatile int | master_beslistener_status = BESLISTENER_STOPPED |
volatile int | num_children = 0 |
void block_signals | ( | ) |
For code that must use signals to stop and start the master listener, block signals being delivered to this process.
The code must call the companion unblock_signals() when it is done.
Definition at line 177 of file daemon.cc.
Referenced by ServerApp::run(), and stop_all_beslisteners().
int main | ( | int | argc, |
char * | argv[] | ||
) |
Run the daemon.
Definition at line 923 of file daemon.cc.
References BESDEBUG, BESLISTENER_RESTART, BESLISTENER_RUNNING, BESLISTENER_STOPPED, BESScrub::command_line_arg_ok(), TheBESKeys::ConfigFile, BESKeys::get_value(), BESDebug::GetOptionsString(), BESModuleApp::initialize(), master_beslistener_status, BESScrub::pathname_ok(), BESDebug::Register(), SERVER_EXIT_FATAL_CANNOT_START, BESDebug::SetStrm(), BESDebug::SetUp(), BESServerUtils::show_usage(), BESServerUtils::show_version(), start_master_beslistener(), TheBESKeys::TheKeys(), and BESLog::TheLog().
int start_master_beslistener | ( | ) |
Start the 'master beslistener' and return its PID.
This function also sets the global 'master_beslistener_pid' so that other code in this file (like the signal handlers) can have access to it. It starts the beslistener using the global 'arguments' that is a copy of the arguments passed to this daemon.
Definition at line 314 of file daemon.cc.
References BESDEBUG, BESLISTENER_PIPE_FD, BESLISTENER_RUNNING, PPTServer::closeConnection(), master_beslistener_status, and update_beslistener_args().
Referenced by main().
bool stop_all_beslisteners | ( | int | sig | ) |
Stop all of the listeners (both the master listener and all of the child listeners that actually process requests).
A test version of this used the master beslistener's exit status to determine if the daemon should try to restart the master beslistener. That feature is retained so that the daemon can start without listening on the BESDaemonPort, thus eliminating a security issue for sites without a firewall.
Uses the master bestistener's process group to send 'sig' to all of the beslisteners.
sig | Signal to send to all beslisteners. |
Definition at line 217 of file daemon.cc.
References BESDEBUG, block_signals(), master_beslistener_status, and unblock_signals().
void unblock_signals | ( | ) |
See block_signals()
Definition at line 191 of file daemon.cc.
Referenced by ServerApp::run(), and stop_all_beslisteners().
char** update_beslistener_args | ( | ) |
Update the arguments passed to the master beslistener so that changes in the debug/log contexts set in the besdaemon will also be set in the beslisteners.
Definition at line 269 of file daemon.cc.
References BESDEBUG, and BESDebug::GetOptionsString().
Referenced by start_master_beslistener().
volatile int master_beslistener_status = BESLISTENER_STOPPED |
Definition at line 94 of file daemon.cc.
Referenced by main(), start_master_beslistener(), and stop_all_beslisteners().