XRootD
Loading...
Searching...
No Matches
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*/
36static const char *XrdFrmOpts = ":bc:dfhk:l:n:s:S:Tvz";
37static 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/*
42Where:
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"
86#include "XrdSys/XrdSysError.hh"
90#include "XrdSys/XrdSysUtils.hh"
91
92using namespace XrdFrc;
93using 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 XrdOucTrace XrdTrace(&Say);
107
108/******************************************************************************/
109/* m a i n */
110/******************************************************************************/
111
112int main(int argc, char *argv[])
113{
115 extern int mainConfig();
116 char *pP;
117
118// Turn off sigpipe and host a variety of others before we start any threads
119//
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);
138 if (!Config.Configure(argc, argv, &mainConfig)) exit(4);
139
140// Fill out the dummy symbol to avoid crashes
141//
143
144// All done, simply exit based on our persona
145//
147}
148
149/******************************************************************************/
150/* m a i n C o n f i g */
151/******************************************************************************/
152
154{
155// Initialize the daemon, depending on who we are to be
156//
157 return (Config.isAgent ? 0 : !XrdFrmXfrDaemon::Init());
158}
static XrdSysLogger Logger
int main(int argc, char *argv[])
XrdOucTrace * XrdXrootdTrace
XrdOucTrace XrdTrace & Say
XrdSysError XrdLog(0, "")
int mainConfig()
static const char * XrdFrmUsage
static const char * XrdFrmOpts
int Configure(int argc, char **argv, int(*ppf)())
static int Start()
static int Init()
XrdSysLogger * logger(XrdSysLogger *lp=0)
static void setStackSize(size_t stsz, bool force=false)
static bool SigBlock()
XrdFrmConfig Config