From 20f5f5c28b773bb4e6164cd4e8df35ef62e3dffd Mon Sep 17 00:00:00 2001 From: John Darrington Date: Sat, 30 Nov 2013 15:30:48 +0100 Subject: [PATCH] guix-daemon: New option --pid-file=FILE * Added a new option to write the daemon's pid to a file. This is necessary for the clean integration into sysV like systems such as used by Debian and other vendors. --- nix/nix-daemon/guix-daemon.cc | 9 +++++++++ nix/sync-with-upstream | 16 ++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/nix/nix-daemon/guix-daemon.cc b/nix/nix-daemon/guix-daemon.cc index 4f9fa4c..d703324 100644 --- a/nix/nix-daemon/guix-daemon.cc +++ b/nix/nix-daemon/guix-daemon.cc @@ -67,6 +67,7 @@ builds derivations on behalf of its clients."; #define GUIX_OPT_CHROOT_DIR 10 #define GUIX_OPT_LISTEN 11 #define GUIX_OPT_NO_SUBSTITUTES 12 +#define GUIX_OPT_PID_FILE 13 static const struct argp_option options[] = { @@ -94,6 +95,8 @@ static const struct argp_option options[] = "Perform builds as a user of GROUP" }, { "no-substitutes", GUIX_OPT_NO_SUBSTITUTES, 0, 0, "Do not use substitutes" }, + { "pid-file", GUIX_OPT_PID_FILE, "FILE", 0, + "Write the daemon's process ID to FILE" }, { "cache-failures", GUIX_OPT_CACHE_FAILURES, 0, 0, "Cache build failures" }, { "lose-logs", GUIX_OPT_LOSE_LOGS, 0, 0, @@ -171,6 +174,9 @@ parse_opt (int key, char *arg, struct argp_state *state) case GUIX_OPT_SYSTEM: settings.thisSystem = arg; break; + case GUIX_OPT_PID_FILE: + settings.nixDaemonPidFile = arg; + break; default: return (error_t) ARGP_ERR_UNKNOWN; } @@ -247,6 +253,9 @@ main (int argc, char *argv[]) printMsg (lvlDebug, format ("listening on `%1%'") % settings.nixDaemonSocketFile); + if (settings.nixDaemonPidFile != "") + writeFile (settings.nixDaemonPidFile, int2String(getpid())); + run (nothing); } catch (std::exception &e) diff --git a/nix/sync-with-upstream b/nix/sync-with-upstream index 535763d..d60406f 100755 --- a/nix/sync-with-upstream +++ b/nix/sync-with-upstream @@ -70,3 +70,19 @@ cp -v "$top_srcdir/nix-upstream/AUTHORS" "$top_srcdir/nix" # Substitutions. sed -i "$top_srcdir/nix/libstore/gc.cc" \ -e 's|/nix/find-runtime-roots\.pl|/guix/list-runtime-roots|g' + + +patch -p 1 << EOF +--- a/nix/libstore/globals.hh 2013-11-30 18:13:33.000000000 +0100 ++++ b/nix/libstore/globals.hh 2013-11-30 18:15:32.000000000 +0100 +@@ -53,6 +53,9 @@ + /* File name of the socket the daemon listens to. */ + Path nixDaemonSocketFile; + ++ /* File name of the to which the daemon PID will be written. */ ++ Path nixDaemonPidFile; ++ + /* Whether to keep temporary directories of failed builds. */ + bool keepFailed; +EOF + -- 1.7.10.4