XRootD
XrdFrmXfrMain.cc
Go to the documentation of this file.
1 /******************************************************************************/
2 /* */
3 /* X r d F r m X f r M a i n . c c */
4 /* */
5 /* (c) 2010 by the Board of Trustees of the Leland Stanford, Jr., University */
6 /* All Rights Reserved */
7 /* Produced by Andrew Hanushevsky for Stanford University under contract */
8 /* DE-AC02-76-SFO0515 with the Department of Energy */
9 /* */
10 /* This file is part of the XRootD software suite. */
11 /* */
12 /* XRootD is free software: you can redistribute it and/or modify it under */
13 /* the terms of the GNU Lesser General Public License as published by the */
14 /* Free Software Foundation, either version 3 of the License, or (at your */
15 /* option) any later version. */
16 /* */
17 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
18 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
19 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
20 /* License for more details. */
21 /* */
22 /* You should have received a copy of the GNU Lesser General Public License */
23 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
24 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
25 /* */
26 /* The copyright holder's institutional names and contributor's names may not */
27 /* be used to endorse or promote products derived from this software without */
28 /* specific prior written permission of the institution or contributor. */
29 /******************************************************************************/
30 
31 /* This is the "main" part of the frm_xfragent & frm_xfrd commands.
32 */
33 
34 /* This is the "main" part of the frm_migrd command. Syntax is:
35 */
36 static const char *XrdFrmOpts = ":bc:dfhk:l:n:s:S:Tvz";
37 static const char *XrdFrmUsage =
38 
39  " [-b] [-c <cfgfn>] [-d] [-f] [-k {num|sz{k|m|g}|sig] [-l [=]<fn>] [-n name]\n"
40  " [-s pidfile] [-S site] [-T] [-v] [-z]\n";
41 /*
42 Where:
43 
44  -b Run as a true daemon in the bacground (only for xfrd).
45 
46  -c The configuration file. The default is '/opt/xrootd/etc/xrootd.cf'
47 
48  -d Turns on debugging mode.
49 
50  -f Fix orphaned files (i.e., lock and pin) by removing them.
51 
52  -k Keeps num log files or no more that sz log files.
53 
54  -l Specifies location of the log file. This may also come from the
55  XrdOucLOGFILE environmental variable.
56  By default, error messages go to standard error.
57 
58  -n The instance name.
59 
60  -s The pidfile name.
61 
62  -S The site name.
63 
64  -T Runs in test mode (no actual migration will occur).
65 
66  -v Verbose mode, typically prints each file details.
67 */
68 
69 /******************************************************************************/
70 /* i n c l u d e f i l e s */
71 /******************************************************************************/
72 
73 #include <unistd.h>
74 #include <cctype>
75 #include <cerrno>
76 #include <cstdlib>
77 #include <cstring>
78 #include <strings.h>
79 #include <cstdio>
80 #include <sys/param.h>
81 
82 #include "XrdFrc/XrdFrcTrace.hh"
83 #include "XrdFrm/XrdFrmConfig.hh"
84 #include "XrdFrm/XrdFrmXfrAgent.hh"
86 #include "XrdSys/XrdSysError.hh"
87 #include "XrdSys/XrdSysHeaders.hh"
88 #include "XrdSys/XrdSysLogger.hh"
89 #include "XrdSys/XrdSysPthread.hh"
90 #include "XrdSys/XrdSysUtils.hh"
91 
92 using namespace XrdFrc;
93 using namespace XrdFrm;
94 
95 /******************************************************************************/
96 /* G l o b a l V a r i a b l e s */
97 /******************************************************************************/
98 
101 
102 // The following is needed to resolve symbols for objects included from xrootd
103 //
106 
107 /******************************************************************************/
108 /* m a i n */
109 /******************************************************************************/
110 
111 int main(int argc, char *argv[])
112 {
114  extern int mainConfig();
115  char *pP;
116 
117 // Turn off sigpipe and host a variety of others before we start any threads
118 //
120 
121 // Set the default stack size here
122 //
123  if (sizeof(long) > 4) XrdSysThread::setStackSize((size_t)1048576);
124  else XrdSysThread::setStackSize((size_t)786432);
125 
126 // If we are named frm_pstg then we are runnng in agent-mode
127 //
128  if (!(pP = rindex(argv[0], '/'))) pP = argv[0];
129  else pP++;
130  if (strncmp("frm_xfrd", pP, 8)) Config.isAgent = 1;
131 
132 
133 // Perform configuration
134 //
135  Say.logger(&Logger);
136  XrdLog.logger(&Logger);
137  if (!Config.Configure(argc, argv, &mainConfig)) exit(4);
138 
139 // All done, simply exit based on our persona
140 //
142 }
143 
144 /******************************************************************************/
145 /* m a i n C o n f i g */
146 /******************************************************************************/
147 
149 {
150 // Initialize the daemon, depending on who we are to be
151 //
152  return (Config.isAgent ? 0 : !XrdFrmXfrDaemon::Init());
153 }
int main(int argc, char *argv[])
XrdSysError XrdLog(0, "")
int mainConfig()
static const char * XrdFrmUsage
static const char * XrdFrmOpts
static int Start()
static int Start()
static int Init()
XrdSysLogger * logger(XrdSysLogger *lp=0)
Definition: XrdSysError.hh:175
static void setStackSize(size_t stsz, bool force=false)
static bool SigBlock()
Definition: XrdSysUtils.cc:188
XrdCmsConfig Config
XrdSysError Say
XrdFrmConfig Config
XrdSysLogger Logger
Definition: XrdGlobals.cc:47
XrdSysTrace XrdTrace
Definition: XrdTrace.hh:56