]> git.proxmox.com Git - ceph.git/blob - ceph/src/ceph_mgr.cc
import ceph quincy 17.2.6
[ceph.git] / ceph / src / ceph_mgr.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2015 Red Hat Inc
7 *
8 * Author: John Spray <john.spray@redhat.com>
9 *
10 * This is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License version 2.1, as published by the Free Software
13 * Foundation. See file COPYING.
14 *
15 */
16
17 #include <Python.h>
18
19 #include <pthread.h>
20
21 #include "include/types.h"
22 #include "include/compat.h"
23 #include "common/config.h"
24 #include "common/ceph_argparse.h"
25 #include "common/errno.h"
26 #include "common/pick_address.h"
27 #include "global/global_init.h"
28
29 #include "mgr/MgrStandby.h"
30
31 static void usage()
32 {
33 std::cout << "usage: ceph-mgr -i <ID> [flags]\n"
34 << std::endl;
35 generic_server_usage();
36 }
37
38 /**
39 * A short main() which just instantiates a MgrStandby and
40 * hands over control to that.
41 */
42 int main(int argc, const char **argv)
43 {
44 ceph_pthread_setname(pthread_self(), "ceph-mgr");
45
46 auto args = argv_to_vec(argc, argv);
47 if (args.empty()) {
48 std::cerr << argv[0] << ": -h or --help for usage" << std::endl;
49 exit(1);
50 }
51 if (ceph_argparse_need_usage(args)) {
52 usage();
53 exit(0);
54 }
55
56 std::map<std::string,std::string> defaults = {
57 { "keyring", "$mgr_data/keyring" }
58 };
59 auto cct = global_init(&defaults, args, CEPH_ENTITY_TYPE_MGR,
60 CODE_ENVIRONMENT_DAEMON, 0);
61
62 pick_addresses(g_ceph_context, CEPH_PICK_ADDRESS_PUBLIC);
63
64 global_init_daemonize(g_ceph_context);
65 global_init_chdir(g_ceph_context);
66 common_init_finish(g_ceph_context);
67
68 MgrStandby mgr(argc, argv);
69 int rc = mgr.init();
70 if (rc != 0) {
71 std::cerr << "Error in initialization: " << cpp_strerror(rc) << std::endl;
72 return rc;
73 }
74
75 return mgr.main(args);
76 }
77