]> git.proxmox.com Git - ceph.git/blob - ceph/src/common/common_init.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / common / common_init.h
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) 2009-2011 New Dream Network
7 *
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
12 *
13 */
14
15 #ifndef CEPH_COMMON_INIT_H
16 #define CEPH_COMMON_INIT_H
17
18 #include <deque>
19
20 #include "include/common_fwd.h"
21 #include "common/code_environment.h"
22
23 enum common_init_flags_t {
24 // Set up defaults that make sense for an unprivileged daemon
25 CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS = 0x1,
26
27 // By default, don't read a configuration file OR contact mons
28 CINIT_FLAG_NO_DEFAULT_CONFIG_FILE = 0x2,
29
30 // Don't close stderr (in daemonize)
31 CINIT_FLAG_NO_CLOSE_STDERR = 0x4,
32
33 // don't do anything daemonish, like create /var/run/ceph, or print a banner
34 CINIT_FLAG_NO_DAEMON_ACTIONS = 0x8,
35
36 // don't drop privileges
37 CINIT_FLAG_DEFER_DROP_PRIVILEGES = 0x10,
38
39 // don't contact mons for config
40 CINIT_FLAG_NO_MON_CONFIG = 0x20,
41
42 // don't expose default cct perf counters
43 CINIT_FLAG_NO_CCT_PERF_COUNTERS = 0x40,
44 };
45
46 #ifndef WITH_SEASTAR
47 class CephInitParameters;
48
49 /*
50 * NOTE: If you are writing a Ceph daemon, ignore this function and call
51 * global_init instead. It will call common_preinit for you.
52 *
53 * common_preinit creates the CephContext.
54 *
55 * After this function gives you a CephContext, you need to set up the
56 * Ceph configuration, which lives inside the CephContext as md_config_t.
57 * The initial settings are not very useful because they do not reflect what
58 * the user asked for.
59 *
60 * This is usually done by something like this:
61 * cct->_conf.parse_env();
62 * cct->_conf.apply_changes();
63 *
64 * Your library may also supply functions to read a configuration file.
65 */
66 CephContext *common_preinit(const CephInitParameters &iparams,
67 enum code_environment_t code_env, int flags);
68 #endif // #ifndef WITH_SEASTAR
69
70 /* Print out some parse error. */
71 void complain_about_parse_error(CephContext *cct,
72 const std::string& parse_error);
73
74 /* This function is called after you have done your last
75 * fork. When you make this call, the system will initialize everything that
76 * cannot be initialized before a fork.
77 *
78 * This includes things like starting threads, initializing libraries that
79 * can't handle forking, and so forth.
80 *
81 * If you are writing a Ceph library, you can call this pretty much any time.
82 * We do not allow our library users to fork and continue using the Ceph
83 * libraries. The most obvious reason for this is that the threads started by
84 * the Ceph libraries would be destroyed by a fork().
85 */
86 void common_init_finish(CephContext *cct);
87
88 #endif