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) 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_GLOBAL_INIT_H
16 #define CEPH_COMMON_GLOBAL_INIT_H
20 #include <boost/intrusive_ptr.hpp>
21 #include "include/assert.h"
22 #include "common/code_environment.h"
23 #include "common/common_init.h"
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.
32 boost::intrusive_ptr
<CephContext
>
33 global_init(std::vector
< const char * > *alt_def_args
,
34 std::vector
< const char* >& args
,
36 code_environment_t code_env
,
38 const char *data_dir_option
= 0,
39 bool run_pre_init
= true);
41 void intrusive_ptr_add_ref(CephContext
* cct
);
42 void intrusive_ptr_release(CephContext
* cct
);
44 // just the first half; enough to get config parsed but doesn't start up the
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
,
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.
56 int global_init_prefork(CephContext
*cct
);
59 * perform all the steps that global_init_daemonize performs just after
60 * the fork, except closing stderr, which we'll do later on.
62 void global_init_postfork_start(CephContext
*cct
);
65 * close stderr, thus completing the postfork.
67 void global_init_postfork_finish(CephContext
*cct
);
71 * global_init_daemonize handles daemonizing a process.
73 * If this is called, it *must* be called before common_init_finish.
74 * Note that this is equivalent to calling _prefork(), daemon(), and
77 void global_init_daemonize(CephContext
*cct
);
80 * global_init_chdir changes the process directory.
82 * If this is called, it *must* be called before common_init_finish
84 void global_init_chdir(const CephContext
*cct
);
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.
91 * If this is called, it *must* be called before common_init_finish
93 int global_init_shutdown_stderr(CephContext
*cct
);
96 * Preload the erasure coding libraries to detect early issues with
99 int global_init_preload_erasure_code(const CephContext
*cct
);
102 * print daemon startup banner/warning
104 void global_print_banner(void);