]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
daemons: write pid file even when told not to daemonize 2535/head
authorAlexandre Oliva <oliva@gnu.org>
Thu, 31 Jul 2014 02:08:43 +0000 (23:08 -0300)
committerLoic Dachary <loic-201408@dachary.org>
Fri, 19 Sep 2014 14:32:51 +0000 (16:32 +0200)
systemd wants to run daemons in foreground, but daemons wouldn't write
out the pid file with -f.  Fixed.

Signed-off-by: Alexandre Oliva <oliva@gnu.org>
(cherry picked from commit bccb0eb64891f65fd475e96b6386494044cae8c1)

src/ceph_mon.cc
src/common/config.cc
src/global/global_init.cc

index 47b6913b77721e49115993d773287acfc68aac00..80b17a14946c05ceb11f0b70975673cd102f584a 100644 (file)
@@ -423,8 +423,7 @@ int main(int argc, const char **argv)
   // screwing us over
   Preforker prefork;
   if (!(flags & CINIT_FLAG_NO_DAEMON_ACTIONS)) {
-    if (g_conf->daemonize) {
-      global_init_prefork(g_ceph_context, 0);
+    if (global_init_prefork(g_ceph_context, 0) >= 0) {
       prefork.prefork();
       if (prefork.is_parent()) {
        return prefork.parent_wait();
index 0e28a83b0a44cfcc82b1a1f6d47a8151674ff551..23bfe351e634eb951be2c9bce5db9c8d666f5734 100644 (file)
@@ -389,12 +389,10 @@ int md_config_t::parse_argv(std::vector<const char*>& args)
     }
     else if (ceph_argparse_flag(args, i, "--foreground", "-f", (char*)NULL)) {
       set_val_or_die("daemonize", "false");
-      set_val_or_die("pid_file", "");
     }
     else if (ceph_argparse_flag(args, i, "-d", (char*)NULL)) {
       set_val_or_die("daemonize", "false");
       set_val_or_die("log_file", "");
-      set_val_or_die("pid_file", "");
       set_val_or_die("log_to_stderr", "true");
       set_val_or_die("err_to_stderr", "true");
       set_val_or_die("log_to_syslog", "false");
index 7b203433b552d15dbfa696b632982bf998fe79a9..f03677c028c39b1348cce5d77078f74b412c5733 100644 (file)
@@ -166,8 +166,16 @@ int global_init_prefork(CephContext *cct, int flags)
   if (g_code_env != CODE_ENVIRONMENT_DAEMON)
     return -1;
   const md_config_t *conf = cct->_conf;
-  if (!conf->daemonize)
+  if (!conf->daemonize) {
+    if (atexit(pidfile_remove_void)) {
+      derr << "global_init_daemonize: failed to set pidfile_remove function "
+          << "to run at exit." << dendl;
+    }
+
+    pidfile_write(g_conf);
+
     return -1;
+  }
 
   // stop log thread
   g_ceph_context->_log->flush();