GNU bug report logs - #39329
[PATCH 0/2] Start guix-daemon in SysV.

Previous Next

Package: guix-patches;

Reported by: Danny Milosavljevic <dannym <at> scratchpost.org>

Date: Tue, 28 Jan 2020 15:57:02 UTC

Severity: normal

Tags: patch

Done: Leo Famulari <leo <at> famulari.name>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 39329 in the body.
You can then email your comments to 39329 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#39329; Package guix-patches. (Tue, 28 Jan 2020 15:57:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Danny Milosavljevic <dannym <at> scratchpost.org>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Tue, 28 Jan 2020 15:57:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: guix-patches <at> gnu.org
Cc: Danny Milosavljevic <dannym <at> scratchpost.org>
Subject: [PATCH 0/2] Start guix-daemon in SysV.
Date: Tue, 28 Jan 2020 16:55:29 +0100
Danny Milosavljevic (2):
  Add system start-up files for guix-daemon.
  guix-install.sh: Install sysv init script.

 .gitignore                |  1 +
 etc/guix-install.sh       | 11 +++++
 etc/init.d/guix-daemon.in | 88 +++++++++++++++++++++++++++++++++++++++
 nix/local.mk              | 16 ++++++-
 4 files changed, 114 insertions(+), 2 deletions(-)
 create mode 100644 etc/init.d/guix-daemon.in





Information forwarded to guix-patches <at> gnu.org:
bug#39329; Package guix-patches. (Tue, 28 Jan 2020 16:00:02 GMT) Full text and rfc822 format available.

Message #8 received at 39329 <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: 39329 <at> debbugs.gnu.org
Cc: Danny Milosavljevic <dannym <at> scratchpost.org>
Subject: [PATCH 2/2] guix-install.sh: Install sysv init script.
Date: Tue, 28 Jan 2020 16:59:00 +0100
* etc/guix-install.sh (sys_enable_guix_daemon): Install sysv init script.
---
 etc/guix-install.sh | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index bfd3842933..f3ea1def32 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -361,6 +361,17 @@ sys_enable_guix_daemon()
                   systemctl enable guix-daemon; } &&
                 _msg "${PAS}enabled Guix daemon via systemd"
             ;;
+        sysv-init)
+            { mkdir -p /etc/init.d;
+              cp "${ROOT_HOME}/.config/guix/current/etc/init.d/guix-daemon" \
+                 /etc/init.d/guix-daemon;
+              chmod 664 /etc/init.d/guix-daemon;
+
+              update-rc.d guix-daemon defaults &&
+                  update-rc.d guix-daemon enable &&
+                  service guix-daemon start; } &&
+                _msg "${PAS}enabled Guix daemon via sysv"
+            ;;
         NA|*)
             _msg "${ERR}unsupported init system; run the daemon manually:"
             echo "  ${ROOT_HOME}/.config/guix/current/bin/guix-daemon --build-users-group=guixbuild"




Information forwarded to guix-patches <at> gnu.org:
bug#39329; Package guix-patches. (Tue, 28 Jan 2020 16:00:03 GMT) Full text and rfc822 format available.

Message #11 received at 39329 <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: 39329 <at> debbugs.gnu.org
Cc: Danny Milosavljevic <dannym <at> scratchpost.org>
Subject: [PATCH 1/2] Add system start-up files for guix-daemon.
Date: Tue, 28 Jan 2020 16:58:59 +0100
* etc/init.d/guix-daemon.in: New file.
* nix/local.mk (etc/init.d/guix-daemon): New rule.
(nodist_sysvinitservice_DATA): Add etc/init.d/guix-daemon.in .
(CLEANFILES): Add etc/init.d/guix-daemon .
* .gitignore: Add etc/init.d/guix-daemon .
---
 .gitignore                |  1 +
 etc/init.d/guix-daemon.in | 88 +++++++++++++++++++++++++++++++++++++++
 nix/local.mk              | 16 ++++++-
 3 files changed, 103 insertions(+), 2 deletions(-)
 create mode 100644 etc/init.d/guix-daemon.in

diff --git a/.gitignore b/.gitignore
index df59a9176e..de058dda5e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -71,6 +71,7 @@
 /etc/guix-daemon.service
 /etc/guix-publish.conf
 /etc/guix-publish.service
+/etc/init.d/guix-daemon
 /guix-daemon
 /guix/config.scm
 /libformat.a
diff --git a/etc/init.d/guix-daemon.in b/etc/init.d/guix-daemon.in
new file mode 100644
index 0000000000..8974a5d215
--- /dev/null
+++ b/etc/init.d/guix-daemon.in
@@ -0,0 +1,88 @@
+#!/bin/bash
+### BEGIN INIT INFO
+# Provides:          guix-daemon
+# Required-Start:    $remote_fs $syslog
+# Required-Stop:     $remote_fs $syslog
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Guix build daemon
+# Description:       Provides a daemon that does builds for Guix
+### END INIT INFO
+
+set -e
+set -o pipefail
+mkdir -p "/var/run"
+if [ ! -f "@localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix-daemon" ]
+then
+  exit 5
+fi
+
+case "$1" in
+start)
+  if [ -f "/var/run/guix-daemon.pid" ]
+  then
+    pid="`cat /var/run/guix-daemon.pid`"
+    if ps www "${pid}" |grep -qa guix-daemon
+    then
+      exit 0
+    else
+      echo "guix-daemon has a stale pid file" >&2
+      exit 1
+    fi
+  else
+    daemonize \
+      -a \
+      -e /var/log/guix-daemon-stderr.log \
+      -o /var/log/guix-daemon-stdout.log \
+      -E GUIX_LOCPATH=@localstatedir@/guix/profiles/per-user/root/guix-profile/lib/locale \
+      -E LC_ALL=en_US.utf8 \
+      -p /var/run/guix-daemon.pid \
+      @localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix-daemon \
+      --build-users-group=guixbuild
+  fi
+  ;;
+stop)
+  if [ -f "/var/run/guix-daemon.pid" ]
+  then
+    pid="`cat /var/run/guix-daemon.pid`"
+    if ps www "${pid}" |grep -qa guix-daemon
+    then
+      kill "${pid}"
+      sleep 10
+      kill -9 "${pid}" || true
+      exit 0
+    else
+      echo "guix-daemon has a stale pid file" >&2
+      exit 1
+    fi
+  else
+    exit 0
+  fi
+  ;;
+status)
+  if [ -f "/var/run/guix-daemon.pid" ]
+  then
+    pid="`cat /var/run/guix-daemon.pid`"
+    if ps www "${pid}" |grep -qa guix-daemon
+    then
+      echo "guix-daemon is running"
+      exit 0
+    else
+      echo "guix-daemon has a stale pid file"
+      exit 1
+    fi
+  else
+    echo "guix-daemon is not running"
+    exit 3
+  fi
+  ;;
+restart)
+force-reload)
+  "$0" stop
+  "$0" start
+  ;;
+*)
+  echo "Usage: $0 (start|stop|status|restart|force-reload)"
+  exit 3
+  ;;
+esac
diff --git a/nix/local.mk b/nix/local.mk
index dc5a8398b2..a64bdd2137 100644
--- a/nix/local.mk
+++ b/nix/local.mk
@@ -164,6 +164,16 @@ etc/guix-%.service: etc/guix-%.service.in	\
 	       "$<" > "$@.tmp";		\
 	mv "$@.tmp" "$@"
 
+sysvinitservicedir = $(sysconfdir)/init.d
+nodist_sysvinitservice_DATA = etc/init.d/guix-daemon
+
+etc/init.d/guix-daemon: etc/init.d/guix-daemon.in	\
+			 $(top_builddir)/config.status
+	$(AM_V_GEN)$(MKDIR_P) "`dirname $@`";	\
+	$(SED) -e 's|@''localstatedir''@|$(localstatedir)|' <	\
+	       "$<" > "$@.tmp";		\
+	mv "$@.tmp" "$@"
+
 # The '.conf' jobs for Upstart.
 upstartjobdir = $(libdir)/upstart/system
 nodist_upstartjob_DATA = etc/guix-daemon.conf etc/guix-publish.conf
@@ -177,7 +187,8 @@ etc/guix-%.conf: etc/guix-%.conf.in	\
 
 CLEANFILES +=					\
   $(nodist_systemdservice_DATA)			\
-  $(nodist_upstartjob_DATA)
+  $(nodist_upstartjob_DATA)			\
+  $(nodist_sysvinitservice_DATA)
 
 EXTRA_DIST +=					\
   %D%/AUTHORS					\
@@ -185,7 +196,8 @@ EXTRA_DIST +=					\
   etc/guix-daemon.service.in			\
   etc/guix-daemon.conf.in			\
   etc/guix-publish.service.in			\
-  etc/guix-publish.conf.in
+  etc/guix-publish.conf.in			\
+  etc/init.d/guix-daemon.in
 
 if CAN_RUN_TESTS
 




Information forwarded to guix-patches <at> gnu.org:
bug#39329; Package guix-patches. (Tue, 28 Jan 2020 16:02:02 GMT) Full text and rfc822 format available.

Message #14 received at 39329 <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: 39329 <at> debbugs.gnu.org
Subject: Re: [PATCH 2/2] guix-install.sh: Install sysv init script.
Date: Tue, 28 Jan 2020 17:01:25 +0100
[Message part 1 (text/plain, inline)]
> +              chmod 664 /etc/init.d/guix-daemon;

775
[Message part 2 (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#39329; Package guix-patches. (Tue, 28 Jan 2020 16:02:02 GMT) Full text and rfc822 format available.

Message #17 received at 39329 <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: 39329 <at> debbugs.gnu.org
Subject: Re: [PATCH 1/2] Add system start-up files for guix-daemon.
Date: Tue, 28 Jan 2020 17:01:58 +0100
[Message part 1 (text/plain, inline)]
On Tue, 28 Jan 2020 16:58:59 +0100
Danny Milosavljevic <dannym <at> scratchpost.org> wrote:

> +    if ps www "${pid}" |grep -qa guix-daemon

If pgrep is standard enough, might want to use that.  Is it?
[Message part 2 (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#39329; Package guix-patches. (Tue, 28 Jan 2020 16:30:02 GMT) Full text and rfc822 format available.

Message #20 received at 39329 <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: 39329 <at> debbugs.gnu.org
Cc: Danny Milosavljevic <dannym <at> scratchpost.org>
Subject: [PATCH v3 1/2] Add system start-up files for guix-daemon.
Date: Tue, 28 Jan 2020 17:29:13 +0100
* etc/init.d/guix-daemon.in: New file.
* nix/local.mk (etc/init.d/guix-daemon): New rule.
(nodist_sysvinitservice_DATA): Add etc/init.d/guix-daemon.in .
(CLEANFILES): Add etc/init.d/guix-daemon .
* .gitignore: Add etc/init.d/guix-daemon .
---
 .gitignore                |  1 +
 etc/init.d/guix-daemon.in | 80 +++++++++++++++++++++++++++++++++++++++
 nix/local.mk              | 16 +++++++-
 3 files changed, 95 insertions(+), 2 deletions(-)
 create mode 100644 etc/init.d/guix-daemon.in

diff --git a/.gitignore b/.gitignore
index df59a9176e..de058dda5e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -71,6 +71,7 @@
 /etc/guix-daemon.service
 /etc/guix-publish.conf
 /etc/guix-publish.service
+/etc/init.d/guix-daemon
 /guix-daemon
 /guix/config.scm
 /libformat.a
diff --git a/etc/init.d/guix-daemon.in b/etc/init.d/guix-daemon.in
new file mode 100644
index 0000000000..b9c99204df
--- /dev/null
+++ b/etc/init.d/guix-daemon.in
@@ -0,0 +1,80 @@
+#!/bin/bash
+### BEGIN INIT INFO
+# Provides:          guix-daemon
+# Required-Start:    $remote_fs $syslog
+# Required-Stop:     $remote_fs $syslog
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Guix build daemon
+# Description:       Provides a daemon that does builds for Guix
+### END INIT INFO
+
+set -e
+mkdir -p "/var/run"
+if [ ! -f "@localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix-daemon" ]
+then
+  exit 5
+fi
+
+case "$1" in
+start)
+  if [ -f "/var/run/guix-daemon.pid" ]
+  then
+    if pgrep -F "/var/run/guix-daemon.pid" guix-daemon
+    then
+      exit 0
+    else
+      echo "guix-daemon has a stale pid file" >&2
+      exit 1
+    fi
+  else
+    daemonize \
+      -a \
+      -e "/var/log/guix-daemon-stderr.log" \
+      -o "/var/log/guix-daemon-stdout.log" \
+      -E GUIX_LOCPATH=@localstatedir@/guix/profiles/per-user/root/guix-profile/lib/locale \
+      -E LC_ALL=en_US.utf8 \
+      -p "/var/run/guix-daemon.pid" \
+      @localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix-daemon \
+      --build-users-group=guixbuild
+  fi
+  ;;
+stop)
+  if [ -f "/var/run/guix-daemon.pid" ]
+  then
+    pkill -F "/var/run/guix-daemon.pid" guix-daemon || {
+      exit 1
+    }
+    sleep 10
+    pkill --signal 9 -F "/var/run/guix-daemon.pid" guix-daemon || true
+    exit 0
+  else
+    exit 0
+  fi
+  ;;
+status)
+  if [ -f "/var/run/guix-daemon.pid" ]
+  then
+    if pgrep -F "/var/run/guix-daemon.pid" guix-daemon
+    then
+      echo "guix-daemon is running"
+      exit 0
+    else
+      echo "guix-daemon has a stale pid file"
+      exit 1
+    fi
+  else
+    echo "guix-daemon is not running"
+    exit 3
+  fi
+  ;;
+restart)
+force-reload)
+  "$0" stop
+  "$0" start
+  ;;
+*)
+  echo "Usage: $0 (start|stop|status|restart|force-reload)"
+  exit 3
+  ;;
+esac
diff --git a/nix/local.mk b/nix/local.mk
index dc5a8398b2..a64bdd2137 100644
--- a/nix/local.mk
+++ b/nix/local.mk
@@ -164,6 +164,16 @@ etc/guix-%.service: etc/guix-%.service.in	\
 	       "$<" > "$@.tmp";		\
 	mv "$@.tmp" "$@"
 
+sysvinitservicedir = $(sysconfdir)/init.d
+nodist_sysvinitservice_DATA = etc/init.d/guix-daemon
+
+etc/init.d/guix-daemon: etc/init.d/guix-daemon.in	\
+			 $(top_builddir)/config.status
+	$(AM_V_GEN)$(MKDIR_P) "`dirname $@`";	\
+	$(SED) -e 's|@''localstatedir''@|$(localstatedir)|' <	\
+	       "$<" > "$@.tmp";		\
+	mv "$@.tmp" "$@"
+
 # The '.conf' jobs for Upstart.
 upstartjobdir = $(libdir)/upstart/system
 nodist_upstartjob_DATA = etc/guix-daemon.conf etc/guix-publish.conf
@@ -177,7 +187,8 @@ etc/guix-%.conf: etc/guix-%.conf.in	\
 
 CLEANFILES +=					\
   $(nodist_systemdservice_DATA)			\
-  $(nodist_upstartjob_DATA)
+  $(nodist_upstartjob_DATA)			\
+  $(nodist_sysvinitservice_DATA)
 
 EXTRA_DIST +=					\
   %D%/AUTHORS					\
@@ -185,7 +196,8 @@ EXTRA_DIST +=					\
   etc/guix-daemon.service.in			\
   etc/guix-daemon.conf.in			\
   etc/guix-publish.service.in			\
-  etc/guix-publish.conf.in
+  etc/guix-publish.conf.in			\
+  etc/init.d/guix-daemon.in
 
 if CAN_RUN_TESTS
 




Information forwarded to guix-patches <at> gnu.org:
bug#39329; Package guix-patches. (Tue, 28 Jan 2020 16:30:03 GMT) Full text and rfc822 format available.

Message #23 received at 39329 <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: 39329 <at> debbugs.gnu.org
Cc: Danny Milosavljevic <dannym <at> scratchpost.org>
Subject: [PATCH v3 0/2] Start guix-daemon on SysV.
Date: Tue, 28 Jan 2020 17:29:12 +0100
Danny Milosavljevic (2):
  Add system start-up files for guix-daemon.
  guix-install.sh: Install sysv init script.

 .gitignore                |  1 +
 etc/guix-install.sh       | 11 ++++++
 etc/init.d/guix-daemon.in | 80 +++++++++++++++++++++++++++++++++++++++
 nix/local.mk              | 16 +++++++-
 4 files changed, 106 insertions(+), 2 deletions(-)
 create mode 100644 etc/init.d/guix-daemon.in





Information forwarded to guix-patches <at> gnu.org:
bug#39329; Package guix-patches. (Tue, 28 Jan 2020 16:30:03 GMT) Full text and rfc822 format available.

Message #26 received at 39329 <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: 39329 <at> debbugs.gnu.org
Cc: Danny Milosavljevic <dannym <at> scratchpost.org>
Subject: [PATCH v3 2/2] guix-install.sh: Install sysv init script.
Date: Tue, 28 Jan 2020 17:29:14 +0100
* etc/guix-install.sh (sys_enable_guix_daemon): Install sysv init script.
---
 etc/guix-install.sh | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index bfd3842933..e7f4d2cd59 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -361,6 +361,17 @@ sys_enable_guix_daemon()
                   systemctl enable guix-daemon; } &&
                 _msg "${PAS}enabled Guix daemon via systemd"
             ;;
+        sysv-init)
+            { mkdir -p /etc/init.d;
+              cp "${ROOT_HOME}/.config/guix/current/etc/init.d/guix-daemon" \
+                 /etc/init.d/guix-daemon;
+              chmod 775 /etc/init.d/guix-daemon;
+
+              update-rc.d guix-daemon defaults &&
+                  update-rc.d guix-daemon enable &&
+                  service guix-daemon start; } &&
+                _msg "${PAS}enabled Guix daemon via sysv"
+            ;;
         NA|*)
             _msg "${ERR}unsupported init system; run the daemon manually:"
             echo "  ${ROOT_HOME}/.config/guix/current/bin/guix-daemon --build-users-group=guixbuild"




Information forwarded to guix-patches <at> gnu.org:
bug#39329; Package guix-patches. (Tue, 28 Jan 2020 17:40:01 GMT) Full text and rfc822 format available.

Message #29 received at 39329 <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: 39329 <at> debbugs.gnu.org
Cc: Danny Milosavljevic <dannym <at> scratchpost.org>
Subject: [PATCH v4 0/2] Start guix-daemon on SysV.
Date: Tue, 28 Jan 2020 18:38:56 +0100
Danny Milosavljevic (2):
  Add system start-up files for guix-daemon.
  guix-install.sh: Install SysV init script.

 .gitignore                |  1 +
 etc/guix-install.sh       | 11 ++++++
 etc/init.d/guix-daemon.in | 78 +++++++++++++++++++++++++++++++++++++++
 nix/local.mk              | 16 +++++++-
 4 files changed, 104 insertions(+), 2 deletions(-)
 create mode 100644 etc/init.d/guix-daemon.in





Information forwarded to guix-patches <at> gnu.org:
bug#39329; Package guix-patches. (Tue, 28 Jan 2020 17:40:02 GMT) Full text and rfc822 format available.

Message #32 received at 39329 <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: 39329 <at> debbugs.gnu.org
Cc: Danny Milosavljevic <dannym <at> scratchpost.org>
Subject: [PATCH v4 2/2] guix-install.sh: Install SysV init script.
Date: Tue, 28 Jan 2020 18:38:58 +0100
* etc/guix-install.sh (sys_enable_guix_daemon): Install SysV init script.
---
 etc/guix-install.sh | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index bfd3842933..e7f4d2cd59 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -361,6 +361,17 @@ sys_enable_guix_daemon()
                   systemctl enable guix-daemon; } &&
                 _msg "${PAS}enabled Guix daemon via systemd"
             ;;
+        sysv-init)
+            { mkdir -p /etc/init.d;
+              cp "${ROOT_HOME}/.config/guix/current/etc/init.d/guix-daemon" \
+                 /etc/init.d/guix-daemon;
+              chmod 775 /etc/init.d/guix-daemon;
+
+              update-rc.d guix-daemon defaults &&
+                  update-rc.d guix-daemon enable &&
+                  service guix-daemon start; } &&
+                _msg "${PAS}enabled Guix daemon via sysv"
+            ;;
         NA|*)
             _msg "${ERR}unsupported init system; run the daemon manually:"
             echo "  ${ROOT_HOME}/.config/guix/current/bin/guix-daemon --build-users-group=guixbuild"




Information forwarded to guix-patches <at> gnu.org:
bug#39329; Package guix-patches. (Tue, 28 Jan 2020 17:40:02 GMT) Full text and rfc822 format available.

Message #35 received at 39329 <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: 39329 <at> debbugs.gnu.org
Cc: Danny Milosavljevic <dannym <at> scratchpost.org>
Subject: [PATCH v4 1/2] Add system start-up files for guix-daemon.
Date: Tue, 28 Jan 2020 18:38:57 +0100
* etc/init.d/guix-daemon.in: New file.
* nix/local.mk (etc/init.d/guix-daemon): New rule.
(nodist_sysvinitservice_DATA): Add etc/init.d/guix-daemon.in .
(CLEANFILES): Add etc/init.d/guix-daemon .
* .gitignore: Add etc/init.d/guix-daemon .
---
 .gitignore                |  1 +
 etc/init.d/guix-daemon.in | 78 +++++++++++++++++++++++++++++++++++++++
 nix/local.mk              | 16 +++++++-
 3 files changed, 93 insertions(+), 2 deletions(-)
 create mode 100644 etc/init.d/guix-daemon.in

diff --git a/.gitignore b/.gitignore
index df59a9176e..de058dda5e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -71,6 +71,7 @@
 /etc/guix-daemon.service
 /etc/guix-publish.conf
 /etc/guix-publish.service
+/etc/init.d/guix-daemon
 /guix-daemon
 /guix/config.scm
 /libformat.a
diff --git a/etc/init.d/guix-daemon.in b/etc/init.d/guix-daemon.in
new file mode 100644
index 0000000000..80bd18eaeb
--- /dev/null
+++ b/etc/init.d/guix-daemon.in
@@ -0,0 +1,78 @@
+#!/bin/bash
+### BEGIN INIT INFO
+# Provides:          guix-daemon
+# Required-Start:    $remote_fs $syslog
+# Required-Stop:     $remote_fs $syslog
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Guix build daemon
+# Description:       Provides a daemon that does builds for Guix
+### END INIT INFO
+
+set -e
+mkdir -p "/var/run"
+if [ ! -f "@localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix-daemon" ]
+then
+  exit 5
+fi
+
+case "$1" in
+start)
+  if [ -f "/var/run/guix-daemon.pid" ]
+  then
+    if pgrep -F "/var/run/guix-daemon.pid" guix-daemon
+    then
+      exit 0
+    else
+      echo "guix-daemon has a stale pid file" >&2
+      exit 1
+    fi
+  else
+    daemonize \
+      -a \
+      -e "/var/log/guix-daemon-stderr.log" \
+      -o "/var/log/guix-daemon-stdout.log" \
+      -E GUIX_LOCPATH=@localstatedir@/guix/profiles/per-user/root/guix-profile/lib/locale \
+      -E LC_ALL=en_US.utf8 \
+      -p "/var/run/guix-daemon.pid" \
+      @localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix-daemon \
+      --build-users-group=guixbuild
+  fi
+  ;;
+stop)
+  if [ -f "/var/run/guix-daemon.pid" ]
+  then
+    pkill -F "/var/run/guix-daemon.pid" guix-daemon || {
+      exit 1
+    }
+    exit 0
+  else
+    exit 0
+  fi
+  ;;
+status)
+  if [ -f "/var/run/guix-daemon.pid" ]
+  then
+    if pgrep -F "/var/run/guix-daemon.pid" guix-daemon
+    then
+      echo "guix-daemon is running"
+      exit 0
+    else
+      echo "guix-daemon has a stale pid file"
+      exit 1
+    fi
+  else
+    echo "guix-daemon is not running"
+    exit 3
+  fi
+  ;;
+restart)
+force-reload)
+  "$0" stop
+  "$0" start
+  ;;
+*)
+  echo "Usage: $0 (start|stop|status|restart|force-reload)"
+  exit 3
+  ;;
+esac
diff --git a/nix/local.mk b/nix/local.mk
index dc5a8398b2..a64bdd2137 100644
--- a/nix/local.mk
+++ b/nix/local.mk
@@ -164,6 +164,16 @@ etc/guix-%.service: etc/guix-%.service.in	\
 	       "$<" > "$@.tmp";		\
 	mv "$@.tmp" "$@"
 
+sysvinitservicedir = $(sysconfdir)/init.d
+nodist_sysvinitservice_DATA = etc/init.d/guix-daemon
+
+etc/init.d/guix-daemon: etc/init.d/guix-daemon.in	\
+			 $(top_builddir)/config.status
+	$(AM_V_GEN)$(MKDIR_P) "`dirname $@`";	\
+	$(SED) -e 's|@''localstatedir''@|$(localstatedir)|' <	\
+	       "$<" > "$@.tmp";		\
+	mv "$@.tmp" "$@"
+
 # The '.conf' jobs for Upstart.
 upstartjobdir = $(libdir)/upstart/system
 nodist_upstartjob_DATA = etc/guix-daemon.conf etc/guix-publish.conf
@@ -177,7 +187,8 @@ etc/guix-%.conf: etc/guix-%.conf.in	\
 
 CLEANFILES +=					\
   $(nodist_systemdservice_DATA)			\
-  $(nodist_upstartjob_DATA)
+  $(nodist_upstartjob_DATA)			\
+  $(nodist_sysvinitservice_DATA)
 
 EXTRA_DIST +=					\
   %D%/AUTHORS					\
@@ -185,7 +196,8 @@ EXTRA_DIST +=					\
   etc/guix-daemon.service.in			\
   etc/guix-daemon.conf.in			\
   etc/guix-publish.service.in			\
-  etc/guix-publish.conf.in
+  etc/guix-publish.conf.in			\
+  etc/init.d/guix-daemon.in
 
 if CAN_RUN_TESTS
 




Information forwarded to guix-patches <at> gnu.org:
bug#39329; Package guix-patches. (Fri, 14 Feb 2020 08:44:01 GMT) Full text and rfc822 format available.

Message #38 received at 39329 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Danny Milosavljevic <dannym <at> scratchpost.org>
Cc: 39329 <at> debbugs.gnu.org
Subject: Re: [bug#39329] [PATCH v4 1/2] Add system start-up files for
 guix-daemon.
Date: Fri, 14 Feb 2020 09:43:26 +0100
Hi Danny,

Danny Milosavljevic <dannym <at> scratchpost.org> skribis:

> * etc/init.d/guix-daemon.in: New file.
> * nix/local.mk (etc/init.d/guix-daemon): New rule.
> (nodist_sysvinitservice_DATA): Add etc/init.d/guix-daemon.in .
> (CLEANFILES): Add etc/init.d/guix-daemon .
> * .gitignore: Add etc/init.d/guix-daemon .

I haven’t tested the SysV script, but it LGTM!

Could you perhaps mention it in “Binary Install” in the manual, right
after Upstart?

Thanks!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#39329; Package guix-patches. (Fri, 14 Feb 2020 08:45:02 GMT) Full text and rfc822 format available.

Message #41 received at 39329 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Danny Milosavljevic <dannym <at> scratchpost.org>
Cc: 39329 <at> debbugs.gnu.org
Subject: Re: [bug#39329] [PATCH v4 2/2] guix-install.sh: Install SysV init
 script.
Date: Fri, 14 Feb 2020 09:44:06 +0100
Danny Milosavljevic <dannym <at> scratchpost.org> skribis:

> * etc/guix-install.sh (sys_enable_guix_daemon): Install SysV init script.

[...]

> +              update-rc.d guix-daemon defaults &&
> +                  update-rc.d guix-daemon enable &&
> +                  service guix-daemon start; } &&
> +                _msg "${PAS}enabled Guix daemon via sysv"

Maybe s/sysv/SysV/ for clarity.

Otherwise LGTM, thank you!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#39329; Package guix-patches. (Wed, 11 Mar 2020 01:50:02 GMT) Full text and rfc822 format available.

Message #44 received at 39329 <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: 39329 <at> debbugs.gnu.org
Subject: Re: [PATCH v4 0/2] Start guix-daemon on SysV.
Date: Wed, 11 Mar 2020 02:49:46 +0100
[Message part 1 (text/plain, inline)]
It might make sense not to use pid files here but to actually test whether the
socket /var/guix/daemon-socket/socket works.

No idea how to do that with just bash.  It would be easy in Python.

Committed v4 to guix master as commits 73fbe04107d38f4561636c74d28d7a4935cbb1ef
and fe60ef998f537e0e71bbb3377d5886ad297821d0.

[Message part 2 (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#39329; Package guix-patches. (Mon, 13 Apr 2020 17:03:01 GMT) Full text and rfc822 format available.

Message #47 received at 39329 <at> debbugs.gnu.org (full text, mbox):

From: Vincent Legoll <vincent.legoll <at> gmail.com>
To: 39329 <at> debbugs.gnu.org
Cc: Danny Milosavljevic <dannym <at> scratchpost.org>
Subject: Re: [PATCH v4 0/2] Start guix-daemon on SysV.
Date: Mon, 13 Apr 2020 19:02:46 +0200
Hello,

shouldn't this issue be closed ?

-- 
Vincent Legoll





Reply sent to Leo Famulari <leo <at> famulari.name>:
You have taken responsibility. (Mon, 13 Apr 2020 17:47:01 GMT) Full text and rfc822 format available.

Notification sent to Danny Milosavljevic <dannym <at> scratchpost.org>:
bug acknowledged by developer. (Mon, 13 Apr 2020 17:47:02 GMT) Full text and rfc822 format available.

Message #52 received at 39329-done <at> debbugs.gnu.org (full text, mbox):

From: Leo Famulari <leo <at> famulari.name>
To: Vincent Legoll <vincent.legoll <at> gmail.com>
Cc: 39329-done <at> debbugs.gnu.org, Danny Milosavljevic <dannym <at> scratchpost.org>
Subject: Re: [bug#39329] [PATCH v4 0/2] Start guix-daemon on SysV.
Date: Mon, 13 Apr 2020 13:46:23 -0400
On Mon, Apr 13, 2020 at 07:02:46PM +0200, Vincent Legoll wrote:
> Hello,
> 
> shouldn't this issue be closed ?

Yup, done!

Feel free to do this in the future by sending a message to
<NNN-done <at> debbugs.gnu.org>, where NNN is the bug number.




Information forwarded to guix-patches <at> gnu.org:
bug#39329; Package guix-patches. (Mon, 13 Apr 2020 18:09:01 GMT) Full text and rfc822 format available.

Message #55 received at 39329 <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: Vincent Legoll <vincent.legoll <at> gmail.com>
Cc: 39329 <at> debbugs.gnu.org
Subject: Re: [PATCH v4 0/2] Start guix-daemon on SysV.
Date: Mon, 13 Apr 2020 20:08:29 +0200
[Message part 1 (text/plain, inline)]
Hi Vincent,

I don't know whether it actually works.

I don't feel great just closing this because of that.

I mean SysV is kinda outdated, so I wouldn't even know how to test it myself.
Would Devuan work?
Or Redhat 6/CentOS 6?

Also, it would be a lot better to just check for
/var/guix/daemon-socket/socket availability and usability--but I have no idea
how to use UNIX domain sockets with bash or with tools that would be available
everywhere.

PID files are awful.
[Message part 2 (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#39329; Package guix-patches. (Mon, 13 Apr 2020 18:22:02 GMT) Full text and rfc822 format available.

Message #58 received at 39329 <at> debbugs.gnu.org (full text, mbox):

From: Leo Famulari <leo <at> famulari.name>
To: Danny Milosavljevic <dannym <at> scratchpost.org>
Cc: Vincent Legoll <vincent.legoll <at> gmail.com>, 39329 <at> debbugs.gnu.org
Subject: Re: [bug#39329] [PATCH v4 0/2] Start guix-daemon on SysV.
Date: Mon, 13 Apr 2020 14:21:45 -0400
On Mon, Apr 13, 2020 at 08:08:29PM +0200, Danny Milosavljevic wrote:
> I don't know whether it actually works.
> 
> I don't feel great just closing this because of that.

Okay, feel free to reopen if you want [0]

> I mean SysV is kinda outdated, so I wouldn't even know how to test it myself.
> Would Devuan work?
> Or Redhat 6/CentOS 6?

I'm sure we will get some bug reports if it doesn't work for them.

> Also, it would be a lot better to just check for
> /var/guix/daemon-socket/socket availability and usability--but I have no idea
> how to use UNIX domain sockets with bash or with tools that would be available
> everywhere.
> 
> PID files are awful.

Yeah... there's a reason everyone switched to systemd.

[0]
https://debbugs.gnu.org/server-control.html




Information forwarded to guix-patches <at> gnu.org:
bug#39329; Package guix-patches. (Tue, 14 Apr 2020 10:41:01 GMT) Full text and rfc822 format available.

Message #61 received at 39329 <at> debbugs.gnu.org (full text, mbox):

From: Vincent Legoll <vincent.legoll <at> gmail.com>
To: Leo Famulari <leo <at> famulari.name>,
 Danny Milosavljevic <dannym <at> scratchpost.org>
Cc: 40601 <at> debbugs.gnu.org, 39329 <at> debbugs.gnu.org
Subject: Re: [bug#39329] [PATCH v4 0/2] Start guix-daemon on SysV.
Date: Tue, 14 Apr 2020 12:40:13 +0200
Hello,


I now have tested the patch series in #40601

also on latest devuan-sysvinit x86_64.


On 13/04/2020 20:21, Leo Famulari wrote:
> On Mon, Apr 13, 2020 at 08:08:29PM +0200, Danny Milosavljevic wrote:
>> I don't know whether it actually works.
>>
>> I don't feel great just closing this because of that.
> Okay, feel free to reopen if you want [0]
>
>> I mean SysV is kinda outdated, so I wouldn't even know how to test it myself.
>> Would Devuan work?
>> Or Redhat 6/CentOS 6?
> I'm sure we will get some bug reports if it doesn't work for them.


Here's the first one: ;-)

the sysvinit init.d script relies on "daemonize" which is not

installed by default on devuan.


Would fixing it by checking a second round of REQUIRED_BY_INIT

after checking the init type be the right way ?


Or should I report an issue about that ?


But if daemonize is installed, the sysvinit support works

as expected, and I can run guix commands as for the

other tests I did.


Thanks


-- 

Vincent Legoll






bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 12 May 2020 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 320 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.