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,
50 const char *data_dir_option = 0);
53 * perform all of the steps that global_init_daemonize performs just prior
54 * to actually forking (via daemon(3)). return 0 if we are going to proceed
55 * with the fork, or -1 otherwise.
57 int global_init_prefork(CephContext *cct);
60 * perform all the steps that global_init_daemonize performs just after
61 * the fork, except closing stderr, which we'll do later on.
63 void global_init_postfork_start(CephContext *cct);
66 * close stderr, thus completing the postfork.
68 void global_init_postfork_finish(CephContext *cct);
72 * global_init_daemonize handles daemonizing a process.
74 * If this is called, it *must* be called before common_init_finish.
75 * Note that this is equivalent to calling _prefork(), daemon(), and
78 void global_init_daemonize(CephContext *cct);
81 * global_init_chdir changes the process directory.
83 * If this is called, it *must* be called before common_init_finish
85 void global_init_chdir(const CephContext *cct);
88 * Explicitly shut down stderr. Usually, you don't need to do
89 * this, because global_init_daemonize will do it for you. However, in some
90 * rare cases you need to call this explicitly.
92 * If this is called, it *must* be called before common_init_finish
94 int global_init_shutdown_stderr(CephContext *cct);
97 * Preload the erasure coding libraries to detect early issues with
100 int global_init_preload_erasure_code(const CephContext *cct);
103 * print daemon startup banner/warning
105 void global_print_banner(void);