From 91ce18168c5fa1a279c07a4f25a4b147a251966b Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 10 Mar 2009 14:43:07 -0700 Subject: [PATCH] config: default to -d for server daemons; -D/--nodaemon for foreground operation --- man/Makefile.am | 4 ++-- man/cosd.8 | 12 +++++------- src/cmds.cc | 1 + src/cmon.cc | 1 + src/config.cc | 14 ++++++++++++++ src/config.h | 3 +++ src/cosd.cc | 3 +-- src/init-ceph | 2 +- src/vstart.sh | 2 +- 9 files changed, 29 insertions(+), 13 deletions(-) diff --git a/man/Makefile.am b/man/Makefile.am index 120ced2e69a31..1e520085a4db7 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -1,4 +1,4 @@ AUTOMAKE_OPTIONS = gnu -man_MANS = cosd.8 -dist_man_MANS = cosd.8 \ No newline at end of file +man_MANS = cosd.8 mkcephfs.8 +dist_man_MANS = cosd.8 mkcephfs.8 \ No newline at end of file diff --git a/man/cosd.8 b/man/cosd.8 index 0d8e6075c2f3b..de62f92904490 100644 --- a/man/cosd.8 +++ b/man/cosd.8 @@ -3,7 +3,6 @@ cosd \- ceph object storage daemon .SH SYNOPSIS .B cosd -[ \fB\-d\fP ] \fIdatapath\fP [ \fB\-j\fI journal\fP ] [ \fB\-c\fI ceph.conf\fP ] @@ -18,16 +17,15 @@ The \fIdatapath\fP argument should be a directory on a btrfs file system where the object data resides. The \fIjournal\fP is optional, and is only useful performance-wise when it resides on a different disk than \fIdatapath\fP with low latency (ideally, an NVRAM device). -.PP -If neither \fB-d\fP nor \fB-f\fP is specified, the daemon will run -in the foreground and log to stdout. .SH OPTIONS .TP -\fB\-d\fP -daemonize after startup. +\fB\-D\fP +Debug mode: do not daemonize after startup (run in foreground) and send log output +to stdout. .TP \fB\-f\fP -do not daemonize after startup (run in foreground). Useful when run via +do not daemonize after startup (run in foreground), but log to the usual location. +Useful when run via .BR crun (8). .TP \fB\-j\fI journal\fP diff --git a/src/cmds.cc b/src/cmds.cc index b79f70aecf525..cebec150126e2 100644 --- a/src/cmds.cc +++ b/src/cmds.cc @@ -38,6 +38,7 @@ int main(int argc, const char **argv) vector args; argv_to_vec(argc, argv, args); env_to_vec(args); + configure_daemon_mode(); common_init(args); // mds specific args diff --git a/src/cmon.cc b/src/cmon.cc index 05e35b4a286a3..09c85646549dd 100644 --- a/src/cmon.cc +++ b/src/cmon.cc @@ -51,6 +51,7 @@ int main(int argc, const char **argv) vector args; argv_to_vec(argc, argv, args); env_to_vec(args); + configure_daemon_mode(); common_init(args); // args diff --git a/src/config.cc b/src/config.cc index f4783ce3fcf58..2390c093675dc 100644 --- a/src/config.cc +++ b/src/config.cc @@ -766,6 +766,9 @@ void parse_startup_config_options(std::vector& args) SET_BOOL_ARG_VAL(&g_conf.dump_conf); } else if (CMD_EQ("bind", 0)) { assert_warn(parse_ip_port(args[++i], g_my_addr)); + } else if (CMD_EQ("nodaemon", 'D')) { + g_conf.daemonize = false; + g_conf.log_to_stdout = true; } else if (CMD_EQ("daemonize", 'd')) { g_conf.daemonize = true; g_conf.log_to_stdout = false; @@ -786,6 +789,17 @@ void parse_startup_config_options(std::vector& args) cf.dump(); } +void configure_daemon_mode() +{ + g_conf.daemonize = true; + g_conf.log_to_stdout = false; +} +void configure_client_mode() +{ + g_conf.daemonize = false; + g_conf.log_to_stdout = true; +} + void parse_config_options(std::vector& args) { int opt_len = sizeof(config_optionsp)/sizeof(config_option); diff --git a/src/config.h b/src/config.h index 6ba5b2f27cf8b..948ca34e8f86e 100644 --- a/src/config.h +++ b/src/config.h @@ -358,6 +358,9 @@ void parse_config_option_string(string& s); extern bool parse_ip_port(const char *s, entity_addr_t& addr, const char **end=0); +void configure_daemon_mode(); +void configure_client_mode(); + class ConfFile; void parse_config_file(ConfFile *cf, bool update); diff --git a/src/cosd.cc b/src/cosd.cc index 349d55807103b..85ce2e146b9f3 100644 --- a/src/cosd.cc +++ b/src/cosd.cc @@ -40,8 +40,6 @@ void usage() cerr << " -d daemonize" << std::endl; cerr << " --debug_osd N set debug level (e.g. 10)" << std::endl; cerr << " --debug_ms N set message debug level (e.g. 1)" << std::endl; - cerr << " --ebofs use EBOFS for object storage (default)" << std::endl; - cerr << " --fakestore store objects as files in directory " << std::endl; exit(1); } @@ -51,6 +49,7 @@ int main(int argc, const char **argv) vector args; argv_to_vec(argc, argv, args); env_to_vec(args); + configure_daemon_mode(); common_init(args); if (g_conf.clock_tare) g_clock.tare(); diff --git a/src/init-ceph b/src/init-ceph index c5170f85a0b73..0b5621a2ed16c 100755 --- a/src/init-ceph +++ b/src/init-ceph @@ -171,7 +171,7 @@ for name in $what; do start) # build final command wrap="" - runflags="-d" + runflags="" runmode="" get_conf_bool crun "$docrun" "restart on core dump" $sections diff --git a/src/vstart.sh b/src/vstart.sh index c3cd9badb821c..84b15fd59db50 100755 --- a/src/vstart.sh +++ b/src/vstart.sh @@ -72,7 +72,7 @@ if [ $start_all -eq 1 ]; then start_osd=1 fi -ARGS="-d -c $conf" +ARGS="-c $conf" if [ $debug -eq 0 ]; then CMON_ARGS="--debug_mon 10 --debug_ms 1" -- 2.39.5