7 #include "cvmfs_config.h"
25 'o',
"File descriptor to use for output"));
27 'w',
"Watchdog stacktrace output dir, "
28 "use without parameter to disable watchdog. "
38 std::string option_string =
"";
40 for (
unsigned j = 0; j < params.size(); ++j) {
41 option_string.push_back(params[j].key());
42 if (!params[j].switch_only()) option_string.push_back(
':');
46 while ((c = getopt(argc, argv, option_string.c_str())) != -1) {
47 bool valid_option =
false;
48 for (
unsigned j = 0; j < params.size(); ++j) {
49 if (c == params[j].key()) {
51 (*arguments)[c].Reset();
52 if (!params[j].switch_only()) {
53 (*arguments)[c].Reset(
new std::string(optarg));
61 "CVMFS gateway services receiver component. Usage:");
62 for (
size_t i = 0; i < params.size(); ++i) {
64 params[i].description().c_str());
70 for (
size_t j = 0; j < params.size(); ++j) {
71 if (!params[j].optional()) {
72 if (arguments->find(params[j].key()) == arguments->end()) {
83 int main(
int argc,
char** argv) {
95 if (arguments.find(
'i') != arguments.end()) {
96 fdin = std::atoi(arguments.find(
'i')->second->c_str());
98 if (arguments.find(
'o') != arguments.end()) {
99 fdout = std::atoi(arguments.find(
'o')->second->c_str());
101 if (arguments.find(
'w') != arguments.end()) {
102 watchdog_out_dir = *arguments.find(
'w')->second;
107 if (watchdog_out_dir !=
"") {
108 if (!
MkdirDeep(watchdog_out_dir, 0755)) {
110 "Failed to create stacktrace directory: %s",
111 watchdog_out_dir.c_str());
116 if (watchdog.
IsValid() ==
false) {
118 "Failed to initialize watchdog");
121 watchdog->
Spawn(watchdog_out_dir +
"/stacktrace." + timestamp);
129 if (!reactor.
Run()) {
131 "Error running CVMFS Receiver event loop");
136 "Runtime error during CVMFS Receiver event loop.\n"
142 "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)
void SetLogSyslogShowPID(bool flag)
std::vector< Parameter > ParameterList
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,...)