]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | ||
3efd9988 FG |
19 | #include <pthread.h> |
20 | ||
7c673cae | 21 | #include "include/types.h" |
3efd9988 | 22 | #include "include/compat.h" |
7c673cae FG |
23 | #include "common/config.h" |
24 | #include "common/ceph_argparse.h" | |
25 | #include "common/errno.h" | |
b5b8bbf5 | 26 | #include "common/pick_address.h" |
7c673cae FG |
27 | #include "global/global_init.h" |
28 | ||
29 | #include "mgr/MgrStandby.h" | |
30 | ||
31f18b77 FG |
31 | static void usage() |
32 | { | |
33 | cout << "usage: ceph-mgr -i <ID> [flags]\n" | |
34 | << std::endl; | |
35 | generic_server_usage(); | |
36 | } | |
7c673cae FG |
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 | { | |
3efd9988 FG |
44 | ceph_pthread_setname(pthread_self(), "ceph-mgr"); |
45 | ||
7c673cae FG |
46 | vector<const char*> args; |
47 | argv_to_vec(argc, argv, args); | |
11fdf7f2 TL |
48 | if (args.empty()) { |
49 | cerr << argv[0] << ": -h or --help for usage" << std::endl; | |
50 | exit(1); | |
51 | } | |
52 | if (ceph_argparse_need_usage(args)) { | |
53 | usage(); | |
54 | exit(0); | |
55 | } | |
7c673cae | 56 | |
11fdf7f2 TL |
57 | map<string,string> defaults = { |
58 | { "keyring", "$mgr_data/keyring" } | |
59 | }; | |
60 | auto cct = global_init(&defaults, args, CEPH_ENTITY_TYPE_MGR, | |
f67539c2 | 61 | CODE_ENVIRONMENT_DAEMON, 0); |
7c673cae | 62 | |
b5b8bbf5 FG |
63 | pick_addresses(g_ceph_context, CEPH_PICK_ADDRESS_PUBLIC); |
64 | ||
7c673cae FG |
65 | global_init_daemonize(g_ceph_context); |
66 | global_init_chdir(g_ceph_context); | |
67 | common_init_finish(g_ceph_context); | |
68 | ||
31f18b77 | 69 | MgrStandby mgr(argc, argv); |
7c673cae FG |
70 | int rc = mgr.init(); |
71 | if (rc != 0) { | |
72 | std::cerr << "Error in initialization: " << cpp_strerror(rc) << std::endl; | |
73 | return rc; | |
74 | } | |
75 | ||
76 | return mgr.main(args); | |
77 | } | |
78 |