1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2009-2011 New Dream Network
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.
15 #ifndef CEPH_COMMON_INIT_H
16 #define CEPH_COMMON_INIT_H
20 #include "common/code_environment.h"
24 enum common_init_flags_t
{
25 // Set up defaults that make sense for an unprivileged daemon
26 CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS
= 0x1,
28 // By default, don't read a configuration file OR contact mons
29 CINIT_FLAG_NO_DEFAULT_CONFIG_FILE
= 0x2,
31 // Don't close stderr (in daemonize)
32 CINIT_FLAG_NO_CLOSE_STDERR
= 0x4,
34 // don't do anything daemonish, like create /var/run/ceph, or print a banner
35 CINIT_FLAG_NO_DAEMON_ACTIONS
= 0x8,
37 // don't drop privileges
38 CINIT_FLAG_DEFER_DROP_PRIVILEGES
= 0x10,
40 // don't contact mons for config
41 CINIT_FLAG_NO_MON_CONFIG
= 0x20,
43 // don't expose default cct perf counters
44 CINIT_FLAG_NO_CCT_PERF_COUNTERS
= 0x40,
48 class CephInitParameters
;
51 * NOTE: If you are writing a Ceph daemon, ignore this function and call
52 * global_init instead. It will call common_preinit for you.
54 * common_preinit creates the CephContext.
56 * After this function gives you a CephContext, you need to set up the
57 * Ceph configuration, which lives inside the CephContext as md_config_t.
58 * The initial settings are not very useful because they do not reflect what
61 * This is usually done by something like this:
62 * cct->_conf.parse_env();
63 * cct->_conf.apply_changes();
65 * Your library may also supply functions to read a configuration file.
67 CephContext
*common_preinit(const CephInitParameters
&iparams
,
68 enum code_environment_t code_env
, int flags
);
69 #endif // #ifndef WITH_SEASTAR
71 /* Print out some parse errors. */
72 void complain_about_parse_errors(CephContext
*cct
,
73 std::deque
<std::string
> *parse_errors
);
75 /* This function is called after you have done your last
76 * fork. When you make this call, the system will initialize everything that
77 * cannot be initialized before a fork.
79 * This includes things like starting threads, initializing libraries that
80 * can't handle forking, and so forth.
82 * If you are writing a Ceph library, you can call this pretty much any time.
83 * We do not allow our library users to fork and continue using the Ceph
84 * libraries. The most obvious reason for this is that the threads started by
85 * the Ceph libraries would be destroyed by a fork().
87 void common_init_finish(CephContext
*cct
);