XrdFrmXfrMain.cc

Go to the documentation of this file.
00001 /******************************************************************************/
00002 /*                                                                            */
00003 /*                      X r d F r m X f r M a i n . c c                       */
00004 /*                                                                            */
00005 /* (c) 2010 by the Board of Trustees of the Leland Stanford, Jr., University  */
00006 /*                            All Rights Reserved                             */
00007 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00008 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
00009 /******************************************************************************/
00010 
00011 //           $Id: XrdFrmXfrMain.cc 35287 2010-09-14 21:19:35Z ganis $
00012 
00013 const char *XrdFrmXfrMainCVSID = "$Id: XrdFrmXfrMain.cc 35287 2010-09-14 21:19:35Z ganis $";
00014 
00015 /* This is the "main" part of the frm_xfragent & frm_xfrd commands.
00016 */
00017 
00018 /* This is the "main" part of the frm_migrd command. Syntax is:
00019 */
00020 static const char *XrdFrmOpts  = ":bc:dfhk:l:n:Tv";
00021 static const char *XrdFrmUsage =
00022 
00023   " [-b] [-c <cfgfn>] [-d] [-f] [-k {num | sz{k|m|g}] [-l <lfile>] [-n name] [-T] [-v]\n";
00024 /*
00025 Where:
00026 
00027    -b     Run as a true daemon in the bacground (only for xfrd).
00028 
00029    -c     The configuration file. The default is '/opt/xrootd/etc/xrootd.cf'
00030 
00031    -d     Turns on debugging mode.
00032 
00033    -f     Fix orphaned files (i.e., lock and pin) by removing them.
00034 
00035    -k     Keeps num log files or no more that sz log files.
00036 
00037    -l     Specifies location of the log file. This may also come from the
00038           XrdOucLOGFILE environmental variable.
00039           By default, error messages go to standard error.
00040 
00041    -n     The instance name.
00042 
00043    -T     Runs in test mode (no actual migration will occur).
00044 
00045    -v     Verbose mode, typically prints each file details.
00046 */
00047 
00048 /******************************************************************************/
00049 /*                         i n c l u d e   f i l e s                          */
00050 /******************************************************************************/
00051   
00052 #include <unistd.h>
00053 #include <ctype.h>
00054 #include <errno.h>
00055 #include <signal.h>
00056 #include <stdlib.h>
00057 #include <string.h>
00058 #include <strings.h>
00059 #include <stdio.h>
00060 #include <sys/param.h>
00061 
00062 #include "XrdFrm/XrdFrmConfig.hh"
00063 #include "XrdFrm/XrdFrmTrace.hh"
00064 #include "XrdFrm/XrdFrmXfrAgent.hh"
00065 #include "XrdFrm/XrdFrmXfrDaemon.hh"
00066 #include "XrdSys/XrdSysError.hh"
00067 #include "XrdSys/XrdSysHeaders.hh"
00068 #include "XrdSys/XrdSysLogger.hh"
00069 #include "XrdSys/XrdSysPthread.hh"
00070 
00071 using namespace XrdFrm;
00072   
00073 /******************************************************************************/
00074 /*                      G l o b a l   V a r i a b l e s                       */
00075 /******************************************************************************/
00076 
00077        XrdFrmConfig       XrdFrm::Config(XrdFrmConfig::ssXfr,
00078                                          XrdFrmOpts, XrdFrmUsage);
00079 
00080 // The following is needed to resolve symbols for objects included from xrootd
00081 //
00082        XrdOucTrace       *XrdXrootdTrace;
00083        XrdSysError        XrdLog(0, "");
00084        XrdOucTrace        XrdTrace(&Say);
00085 
00086 /******************************************************************************/
00087 /*                                  m a i n                                   */
00088 /******************************************************************************/
00089   
00090 int main(int argc, char *argv[])
00091 {
00092    XrdSysLogger Logger;
00093    extern int mainConfig();
00094    sigset_t myset;
00095    char *pP;
00096 
00097 // Turn off sigpipe and host a variety of others before we start any threads
00098 //
00099    signal(SIGPIPE, SIG_IGN);  // Solaris optimization
00100    sigemptyset(&myset);
00101    sigaddset(&myset, SIGPIPE);
00102    sigaddset(&myset, SIGCHLD);
00103    pthread_sigmask(SIG_BLOCK, &myset, NULL);
00104 
00105 // Set the default stack size here
00106 //
00107    if (sizeof(long) > 4) XrdSysThread::setStackSize((size_t)1048576);
00108       else               XrdSysThread::setStackSize((size_t)786432);
00109 
00110 // If we are named frm_pstg then we are runnng in agent-mode
00111 //
00112     if (!(pP = rindex(argv[0], '/'))) pP = argv[0];
00113        else pP++;
00114    if (strcmp("frm_xfrd", pP)) Config.isAgent = 1;
00115 
00116 // Perform configuration
00117 //
00118    Say.logger(&Logger);
00119    XrdLog.logger(&Logger);
00120    if (!Config.Configure(argc, argv, &mainConfig)) exit(4);
00121 
00122 // Fill out the dummy symbol to avoid crashes
00123 //
00124    XrdXrootdTrace = new XrdOucTrace(&Say);
00125 
00126 // All done, simply exit based on our persona
00127 //
00128    exit(Config.isAgent ? XrdFrmXfrAgent::Start() : XrdFrmXfrDaemon::Start());
00129 }
00130 
00131 /******************************************************************************/
00132 /*                            m a i n C o n f i g                             */
00133 /******************************************************************************/
00134   
00135 int mainConfig()
00136 {
00137 // Initialize the daemon, depending on who we are to be
00138 //
00139    return (Config.isAgent ? 0 : !XrdFrmXfrDaemon::Init());
00140 }

Generated on Tue Jul 5 14:46:36 2011 for ROOT_528-00b_version by  doxygen 1.5.1