<< "result is " << out->length() << " bytes" << dendl;
}
-
-static bool is_daemon(uint32_t module_type)
-{
- if (module_type == CEPH_ENTITY_TYPE_OSD ||
- module_type == CEPH_ENTITY_TYPE_MDS ||
- module_type == CEPH_ENTITY_TYPE_MON) {
- return true;
- } else {
- return false;
- }
-}
-
-CephContext::CephContext(uint32_t module_type_, int init_flags_)
+CephContext::CephContext(uint32_t module_type_,
+ enum code_environment_t code_env,
+ int init_flags_)
: nref(1),
- _conf(new md_config_t(is_daemon(module_type_))),
+ _conf(new md_config_t(code_env == CODE_ENVIRONMENT_DAEMON)),
_log(NULL),
_module_type(module_type_),
_init_flags(init_flags_),
#include <boost/noncopyable.hpp>
#include "common/cmdparse.h"
+#include "common/code_environment.h"
#include "crush/CrushLocation.h"
#include "include/Spinlock.h"
*/
class CephContext {
public:
- CephContext(uint32_t module_type_, int init_flags_ = 0);
+ CephContext(uint32_t module_type_,
+ enum code_environment_t code_env=CODE_ENVIRONMENT_UTILITY,
+ int init_flags_ = 0);
// ref count!
private:
g_code_env = code_env;
// Create a configuration object
- CephContext *cct = new CephContext(iparams.module_type, flags);
+ CephContext *cct = new CephContext(iparams.module_type, code_env, flags);
md_config_t *conf = cct->_conf;
// add config observers here
if (data_dir_option)
conf->data_dir_option = data_dir_option;
- // Set some defaults based on code type
- switch (code_env) {
- case CODE_ENVIRONMENT_DAEMON:
- conf->set_val_or_die("daemonize", "true");
- conf->set_val_or_die("log_to_stderr", "false");
- conf->set_val_or_die("err_to_stderr", "true");
-
- // different default keyring locations for osd and mds. this is
- // for backward compatibility. moving forward, we want all keyrings
- // in these locations. the mon already forces $mon_data/keyring.
- if (conf->name.is_mds())
- conf->set_val("keyring", "$mds_data/keyring", false);
- else if (conf->name.is_osd())
- conf->set_val("keyring", "$osd_data/keyring", false);
- break;
-
- case CODE_ENVIRONMENT_UTILITY_NODOUT:
- case CODE_ENVIRONMENT_LIBRARY:
+ // different default keyring locations for osd and mds. this is
+ // for backward compatibility. moving forward, we want all keyrings
+ // in these locations. the mon already forces $mon_data/keyring.
+ if (conf->name.is_mds()) {
+ conf->set_val("keyring", "$mds_data/keyring", false);
+ } else if (conf->name.is_osd()) {
+ conf->set_val("keyring", "$osd_data/keyring", false);
+ }
+
+ if (code_env == CODE_ENVIRONMENT_LIBRARY) {
conf->set_val_or_die("log_to_stderr", "false");
conf->set_val_or_die("err_to_stderr", "false");
conf->set_val_or_die("log_flush_on_exit", "false");
- break;
-
- default:
- break;
- }
-
- if (flags & CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS) {
- // do nothing special! we used to do no default log, pid_file,
- // admin_socket, but changed our minds. let's make ceph-fuse
- // and radosgw use the same defaults as ceph-{osd,mon,mds,...}
- } else if (code_env != CODE_ENVIRONMENT_DAEMON) {
- // no default log, pid_file, admin_socket
- conf->set_val_or_die("pid_file", "");
- conf->set_val_or_die("admin_socket", "");
- conf->set_val_or_die("log_file", "");
- // use less memory for logs
- conf->set_val_or_die("log_max_recent", "500");
}
return cct;
.add_see_also("admin_socket"),
Option("admin_socket", Option::TYPE_STR, Option::LEVEL_ADVANCED)
- .set_default("$run_dir/$cluster-$name.asok")
+ .set_default("")
+ .set_daemon_default("$run_dir/$cluster-$name.asok")
.set_description("path for the runtime control socket file, used by the 'ceph daemon' command")
.add_service("common"),
// daemon
Option("daemonize", Option::TYPE_BOOL, Option::LEVEL_ADVANCED)
.set_default(false)
+ .set_daemon_default(true)
.set_description("whether to daemonize (background) after startup")
.add_service("mon mgr osd mds")
.add_tag("service")
// logging
Option("log_file", Option::TYPE_STR, Option::LEVEL_BASIC)
- .set_default("/var/log/ceph/$cluster-$name.log")
+ .set_default("")
+ .set_daemon_default("/var/log/ceph/$cluster-$name.log")
.set_description("path to log file")
.add_see_also("log_to_stderr")
.add_see_also("err_to_stderr")
.add_see_also("log_max_recent"),
Option("log_max_recent", Option::TYPE_INT, Option::LEVEL_ADVANCED)
- .set_default(10000)
+ .set_default(500)
+ .set_daemon_default(10000)
.set_description("recent log entries to keep in memory to dump in the event of a crash")
.set_long_description("The purpose of this option is to log at a higher debug level only to the in-memory buffer, and write out the detailed log messages only if there is a crash. Only log entries below the lower log level will be written unconditionally to the log. For example, debug_osd=1/5 will write everything <= 1 to the log unconditionally but keep entries at levels 2-5 in memory. If there is a seg fault or assertion failure, all entries will be dumped to the log."),
Option("log_to_stderr", Option::TYPE_BOOL, Option::LEVEL_BASIC)
.set_default(true)
+ .set_daemon_default(false)
.set_description("send log lines to stderr"),
Option("err_to_stderr", Option::TYPE_BOOL, Option::LEVEL_BASIC)
.set_default(false)
+ .set_daemon_default(true)
.set_description("send critical error log lines to stderr"),
Option("log_to_syslog", Option::TYPE_BOOL, Option::LEVEL_BASIC)