26 'o',
"File descriptor to use for output"));
28 'w',
"Watchdog stacktrace output dir, "
29 "use without parameter to disable watchdog. "
32 'd',
"Path to debug log. Ignored if the non-debug version runs, "
42 std::string option_string =
"";
44 for (
unsigned j = 0; j < params.size(); ++j) {
45 option_string.push_back(params[j].key());
46 if (!params[j].switch_only()) option_string.push_back(
':');
50 while ((c = getopt(argc, argv, option_string.c_str())) != -1) {
51 bool valid_option =
false;
52 for (
unsigned j = 0; j < params.size(); ++j) {
53 if (c == params[j].key()) {
55 (*arguments)[c].Reset();
56 if (!params[j].switch_only()) {
57 (*arguments)[c].Reset(
new std::string(optarg));
65 "CVMFS gateway services receiver component. Usage:");
66 for (
size_t i = 0; i < params.size(); ++i) {
68 params[i].description().c_str());
74 for (
size_t j = 0; j < params.size(); ++j) {
75 if (!params[j].optional()) {
76 if (arguments->find(params[j].key()) == arguments->end()) {
87 int main(
int argc,
char** argv) {
109 if (arguments.find(
'i') != arguments.end()) {
110 fdin = std::atoi(arguments.find(
'i')->second->c_str());
112 if (arguments.find(
'o') != arguments.end()) {
113 fdout = std::atoi(arguments.find(
'o')->second->c_str());
115 if (arguments.find(
'w') != arguments.end()) {
116 watchdog_out_dir = *arguments.find(
'w')->second;
118 if (arguments.find(
'd') != arguments.end()) {
119 debug_log = *arguments.find(
'd')->second;
127 if (watchdog_out_dir !=
"") {
128 if (!
MkdirDeep(watchdog_out_dir, 0755)) {
130 "Failed to create stacktrace directory: %s",
131 watchdog_out_dir.c_str());
136 if (watchdog.
IsValid() ==
false) {
138 "Failed to initialize watchdog");
141 watchdog->
Spawn(watchdog_out_dir +
"/stacktrace." + timestamp);
149 if (!reactor.
Run()) {
151 "Error running CVMFS Receiver event loop");
156 "Runtime error during CVMFS Receiver event loop.\n"
162 "Unknown error during CVMFS Receiver event loop.\n");
static Parameter Optional(const char key, const std::string &desc)
void SetLogSyslogFacility(const int local_facility)
std::string GetGMTimestamp(const std::string &format)
static const char * kDefaultDebugLog
void SetLogSyslogShowPID(bool flag)
std::vector< Parameter > ParameterList
#define SetLogDebugFile(filename)
static const char * kDefaultReceiverLogDir
static Watchdog * Create(FnOnCrash on_crash)
bool MkdirDeep(const std::string &path, const mode_t mode, bool verify_writable)
bool ReadCmdLineArguments(int argc, char **argv, const swissknife::ParameterList ¶ms, swissknife::ArgumentList *arguments)
swissknife::ParameterList MakeParameterList()
std::map< char, SharedPtr< std::string > > ArgumentList
void Spawn(const std::string &crash_dump_path)
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)