// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab /* * Ceph - scalable distributed file system * * Copyright (C) 2004-2006 Sage Weil * * This is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License version 2.1, as published by the Free Software * Foundation. See file COPYING. * */ #include #include #include #include #include #include using namespace std; #include "config.h" #include "mon/MonMap.h" #include "mon/Monitor.h" #include "mon/MonitorStore.h" #include "msg/SimpleMessenger.h" #include "common/Timer.h" void usage() { cerr << "usage: ./cmon [flags] " << std::endl; cerr << " -d daemonize" << std::endl; cerr << " -o log output to dir/mon#" << std::endl; cerr << " --debug_mon n debug monitor level (e.g. 10)" << std::endl; cerr << " --debug_ms n debug messaging level (e.g. 1)" << std::endl; exit(1); } int main(int argc, const char **argv) { int err; vector args; argv_to_vec(argc, argv, args); parse_config_options(args); // args const char *fsdir = 0; for (unsigned i=0; i= monmap.size() || whoami < 0) { cerr << "mon" << whoami << " does not exist in monmap" << std::endl; exit(1); } // bind cout << "starting mon" << whoami << " at " << monmap.get_inst(whoami).addr << " from " << fsdir << std::endl; g_my_addr = monmap.get_inst(whoami).addr; err = rank.bind(); if (err < 0) return 1; _dout_create_courtesy_output_symlink("mon", whoami); // start monitor Messenger *m = rank.register_entity(entity_name_t::MON(whoami)); m->set_default_send_priority(CEPH_MSG_PRIO_HIGH); Monitor *mon = new Monitor(whoami, &store, m, &monmap); rank.start(); // may daemonize rank.set_policy(entity_name_t::TYPE_MON, Rank::Policy::lossless()); rank.set_policy(entity_name_t::TYPE_MDS, Rank::Policy::lossy_fast_fail()); rank.set_policy(entity_name_t::TYPE_CLIENT, Rank::Policy::lossy_fast_fail()); rank.set_policy(entity_name_t::TYPE_OSD, Rank::Policy::lossy_fast_fail()); rank.set_policy(entity_name_t::TYPE_ADMIN, Rank::Policy::lossy_fast_fail()); mon->init(); rank.wait(); store.umount(); delete mon; // cd on exit, so that gmon.out (if any) goes into a separate directory for each node. char s[20]; sprintf(s, "gmon/%d", getpid()); if (mkdir(s, 0755) == 0) chdir(s); return 0; }