]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
global: create /var/run/ceph on daemon startup
authorSage Weil <sage@inktank.com>
Sat, 8 Jun 2013 00:03:41 +0000 (17:03 -0700)
committerSage Weil <sage@inktank.com>
Thu, 13 Jun 2013 00:47:57 +0000 (17:47 -0700)
This handles cases where the daemon is started without the benefit of
sysvinit or upstart (as with teuthology or ceph-fuse).

Signed-off-by: Sage Weil <sage@inktank.com>
src/common/config_opts.h
src/global/global_init.cc

index a6b380b0b409b420fd64807b6abe12fc44ad1537..9d96b9c8bcace2917b281c0746de0f41d34c0eaa 100644 (file)
@@ -23,7 +23,8 @@ OPTION(num_client, OPT_INT, 1)
 OPTION(monmap, OPT_STR, "")
 OPTION(mon_host, OPT_STR, "")
 OPTION(lockdep, OPT_BOOL, false)
-OPTION(admin_socket, OPT_STR, "/var/run/ceph/$cluster-$name.asok") // default changed by common_preinit()
+OPTION(run_dir, OPT_STR, "/var/run/ceph")       // the "/var/run/ceph" dir, created on daemon startup
+OPTION(admin_socket, OPT_STR, "run_dir/$cluster-$name.asok") // default changed by common_preinit()
 
 OPTION(daemonize, OPT_BOOL, false) // default changed by common_preinit()
 OPTION(pid_file, OPT_STR, "") // default changed by common_preinit()
index e8bfb1688540e73b170952ac9b219adc648972d3..8363d0e191a36fd26aec36eb328e6b044c2056de 100644 (file)
@@ -119,6 +119,15 @@ void global_init(std::vector < const char * > *alt_def_args, std::vector < const
   if (g_conf->log_flush_on_exit)
     g_ceph_context->_log->set_flush_on_exit();
 
+  if (g_conf->run_dir.length() &&
+      code_env == CODE_ENVIRONMENT_DAEMON) {
+    int r = ::mkdir(g_conf->run_dir.c_str(), 0755);
+    if (r < 0 && errno != EEXIST) {
+      r = -errno;
+      derr << "warning: unable to create " << g_conf->run_dir << ": " << cpp_strerror(r) << dendl;
+    }
+  }
+
   if (g_lockdep) {
     dout(1) << "lockdep is enabled" << dendl;
     lockdep_register_ceph_context(cct);