]> git.proxmox.com Git - ceph.git/blob - ceph/src/global/global_init.h
3ef7647cdd3f0d1763e2490911b32d1f3ad1bb12
[ceph.git] / ceph / src / global / global_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) 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_GLOBAL_INIT_H
16 #define CEPH_COMMON_GLOBAL_INIT_H
17
18 #include <stdint.h>
19 #include <vector>
20 #include <boost/intrusive_ptr.hpp>
21 #include "include/assert.h"
22 #include "common/code_environment.h"
23 #include "common/common_init.h"
24
25 class CephContext;
26
27 /*
28 * global_init is the first initialization function that
29 * daemons and utility programs need to call. It takes care of a lot of
30 * initialization, including setting up g_ceph_context.
31 */
32 boost::intrusive_ptr<CephContext>
33 global_init(std::vector < const char * > *alt_def_args,
34 std::vector < const char* >& args,
35 uint32_t module_type,
36 code_environment_t code_env,
37 int flags,
38 const char *data_dir_option = 0,
39 bool run_pre_init = true);
40
41 void intrusive_ptr_add_ref(CephContext* cct);
42 void intrusive_ptr_release(CephContext* cct);
43
44 // just the first half; enough to get config parsed but doesn't start up the
45 // cct or log.
46 void global_pre_init(std::vector < const char * > *alt_def_args,
47 std::vector < const char* >& args,
48 uint32_t module_type, code_environment_t code_env,
49 int flags);
50
51 /*
52 * perform all of the steps that global_init_daemonize performs just prior
53 * to actually forking (via daemon(3)). return 0 if we are going to proceed
54 * with the fork, or -1 otherwise.
55 */
56 int global_init_prefork(CephContext *cct);
57
58 /*
59 * perform all the steps that global_init_daemonize performs just after
60 * the fork, except closing stderr, which we'll do later on.
61 */
62 void global_init_postfork_start(CephContext *cct);
63
64 /*
65 * close stderr, thus completing the postfork.
66 */
67 void global_init_postfork_finish(CephContext *cct);
68
69
70 /*
71 * global_init_daemonize handles daemonizing a process.
72 *
73 * If this is called, it *must* be called before common_init_finish.
74 * Note that this is equivalent to calling _prefork(), daemon(), and
75 * _postfork.
76 */
77 void global_init_daemonize(CephContext *cct);
78
79 /*
80 * global_init_chdir changes the process directory.
81 *
82 * If this is called, it *must* be called before common_init_finish
83 */
84 void global_init_chdir(const CephContext *cct);
85
86 /*
87 * Explicitly shut down stderr. Usually, you don't need to do
88 * this, because global_init_daemonize will do it for you. However, in some
89 * rare cases you need to call this explicitly.
90 *
91 * If this is called, it *must* be called before common_init_finish
92 */
93 int global_init_shutdown_stderr(CephContext *cct);
94
95 /*
96 * Preload the erasure coding libraries to detect early issues with
97 * configuration.
98 */
99 int global_init_preload_erasure_code(const CephContext *cct);
100
101 /**
102 * print daemon startup banner/warning
103 */
104 void global_print_banner(void);
105
106 #endif