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 () |
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 () |
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 | |
int | master_beslistener_status = BESLISTENER_STOPPED |
void block_signals | ( | ) |
Definition at line 166 of file daemon.cc.
Referenced by stop_all_beslisteners().
int main | ( | int | argc, |
char * | argv[] | ||
) |
Run the daemon.
Definition at line 875 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_CAN_NOT_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 302 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 204 of file daemon.cc.
References BESDEBUG, block_signals(), master_beslistener_status, and unblock_signals().
void unblock_signals | ( | ) |
Definition at line 179 of file daemon.cc.
Referenced by 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 257 of file daemon.cc.
References BESDEBUG, and BESDebug::GetOptionsString().
Referenced by start_master_beslistener().
int master_beslistener_status = BESLISTENER_STOPPED |
Definition at line 93 of file daemon.cc.
Referenced by main(), start_master_beslistener(), and stop_all_beslisteners().