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
"
85
#include "
XrdFrm/XrdFrmXfrDaemon.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
99
XrdFrmConfig
XrdFrm::Config
(
XrdFrmConfig::ssXfr
,
100
XrdFrmOpts
,
XrdFrmUsage
);
101
102
// The following is needed to resolve symbols for objects included from xrootd
103
//
104
XrdOucTrace
*
XrdXrootdTrace
;
105
XrdSysError
XrdLog
(0,
""
);
106
XrdOucTrace
XrdTrace
(&
Say
);
107
108
/******************************************************************************/
109
/* m a i n */
110
/******************************************************************************/
111
112
int
main
(
int
argc,
char
*argv[])
113
{
114
XrdSysLogger
Logger
;
115
extern
int
mainConfig
();
116
char
*pP;
117
118
// Turn off sigpipe and host a variety of others before we start any threads
119
//
120
XrdSysUtils::SigBlock
();
121
122
// Set the default stack size here
123
//
124
if
(
sizeof
(
long
) > 4)
XrdSysThread::setStackSize
((
size_t
)1048576);
125
else
XrdSysThread::setStackSize
((
size_t
)786432);
126
127
// If we are named frm_pstg then we are runnng in agent-mode
128
//
129
if
(!(pP = rindex(argv[0],
'/'
))) pP = argv[0];
130
else
pP++;
131
if
(strncmp(
"frm_xfrd"
, pP, 8))
Config
.isAgent = 1;
132
133
134
// Perform configuration
135
//
136
Say
.
logger
(&
Logger
);
137
XrdLog
.
logger
(&
Logger
);
138
if
(!
Config
.Configure(argc, argv, &
mainConfig
)) exit(4);
139
140
// Fill out the dummy symbol to avoid crashes
141
//
142
XrdXrootdTrace
=
new
XrdOucTrace
(&
Say
);
143
144
// All done, simply exit based on our persona
145
//
146
exit(
Config
.isAgent ?
XrdFrmXfrAgent::Start
() :
XrdFrmXfrDaemon::Start
());
147
}
148
149
/******************************************************************************/
150
/* m a i n C o n f i g */
151
/******************************************************************************/
152
153
int
mainConfig
()
154
{
155
// Initialize the daemon, depending on who we are to be
156
//
157
return
(
Config
.isAgent ? 0 : !
XrdFrmXfrDaemon::Init
());
158
}
XrdFrcTrace.hh
XrdFrmConfig.hh
XrdFrmXfrAgent.hh
XrdFrmXfrDaemon.hh
main
int main(int argc, char *argv[])
Definition:
XrdFrmXfrMain.cc:112
XrdXrootdTrace
XrdOucTrace * XrdXrootdTrace
Definition:
XrdFrmXfrMain.cc:104
XrdLog
XrdSysError XrdLog(0, "")
mainConfig
int mainConfig()
Definition:
XrdFrmXfrMain.cc:153
XrdFrmUsage
static const char * XrdFrmUsage
Definition:
XrdFrmXfrMain.cc:37
XrdFrmOpts
static const char * XrdFrmOpts
Definition:
XrdFrmXfrMain.cc:36
XrdSysError.hh
XrdSysHeaders.hh
XrdSysLogger.hh
XrdSysPthread.hh
XrdSysUtils.hh
XrdFrmConfig
Definition:
XrdFrmConfig.hh:54
XrdFrmConfig::ssXfr
@ ssXfr
Definition:
XrdFrmConfig.hh:175
XrdFrmXfrAgent::Start
static int Start()
Definition:
XrdFrmXfrAgent.cc:240
XrdFrmXfrDaemon::Start
static int Start()
Definition:
XrdFrmXfrDaemon.cc:198
XrdFrmXfrDaemon::Init
static int Init()
Definition:
XrdFrmXfrDaemon.cc:95
XrdOucTrace
Definition:
XrdOucTrace.hh:36
XrdSysError
Definition:
XrdSysError.hh:90
XrdSysError::logger
XrdSysLogger * logger(XrdSysLogger *lp=0)
Definition:
XrdSysError.hh:141
XrdSysLogger
Definition:
XrdSysLogger.hh:53
XrdSysThread::setStackSize
static void setStackSize(size_t stsz, bool force=false)
Definition:
XrdSysPthread.cc:330
XrdSysUtils::SigBlock
static bool SigBlock()
Definition:
XrdSysUtils.cc:188
XrdCms::Config
XrdCmsConfig Config
Definition:
XrdCmsConfig.cc:108
XrdFrc
Definition:
XrdFrcCID.hh:96
XrdFrc::Say
XrdSysError Say
XrdFrm
Definition:
XrdFrmAdmin.hh:229
XrdFrm::Config
XrdFrmConfig Config
XrdGlobal::Logger
XrdSysLogger Logger
Definition:
XrdGlobals.cc:47
XrdGlobal::XrdTrace
XrdSysTrace XrdTrace
Definition:
XrdTrace.hh:56
XrdFrm
XrdFrmXfrMain.cc
Generated by
1.9.1