From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Subject: bug#22039: 'guix system reconfigure' must start/restart/stop services Date: Sat, 28 Nov 2015 17:35:10 +0100 Message-ID: <874mg6rsjl.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38131) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a2iTm-0002KO-1W for bug-guix@gnu.org; Sat, 28 Nov 2015 11:36:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a2iTi-0006ke-Py for bug-guix@gnu.org; Sat, 28 Nov 2015 11:36:05 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:40369) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a2iTi-0006ka-MI for bug-guix@gnu.org; Sat, 28 Nov 2015 11:36:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1a2iTi-0001zZ-In for bug-guix@gnu.org; Sat, 28 Nov 2015 11:36:02 -0500 Sender: "Debbugs-submit" Resent-Message-ID: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37750) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a2iSy-0001wp-CR for bug-guix@gnu.org; Sat, 28 Nov 2015 11:35:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a2iSv-0006Wm-5z for bug-guix@gnu.org; Sat, 28 Nov 2015 11:35:16 -0500 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:36707) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a2iSv-0006Wf-24 for bug-guix@gnu.org; Sat, 28 Nov 2015 11:35:13 -0500 Received: from reverse-83.fdn.fr ([80.67.176.83]:48472 helo=pluto) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1a2iSt-0002au-U8 for bug-guix@gnu.org; Sat, 28 Nov 2015 11:35:12 -0500 List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org To: 22039@debbugs.gnu.org Hello! Currently =E2=80=98guix system reconfigure=E2=80=99 doesn=E2=80=99t try to = dynamically update the set of running services, which is a shame. A simple strategy would be to have it: 1. Stop and unregister services currently known to dmd that are missing in the new configuration. 2. Load and start (if they have =E2=80=98auto-start?=E2=80=99) services t= hat are in the new configuration and currently unknown to dmd. 3. The rest is the most difficult part: dealing with services that already exist but that have changed (see below.) One step towards this has been the fact that each service has its code in a module of its own (commit fae685b), making it easy to have dmd load it. For #3, the difficulty is that we cannot do deco stop/load/start for core services like udev or file-system-root because stopping these would effectively halt the system. However, we can safely restart services that are leaves of the dmd graph (unless the user explicitly asks not to do it.) Here=E2=80=99s what it wou= ld mean on my system, which uses =E2=80=98%desktop-services=E2=80=99 and a few= more: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> ,use(guix) scheme@(guile-user)> ,use(gnu) scheme@(guile-user)> ,use(gnu services dmd) scheme@(guile-user)> (define os (load "/home/ludo/src/configuration/pluto-c= onfiguration.scm")) scheme@(guile-user)> ,use(gnu services) scheme@(guile-user)> (define dmds (fold-services (operating-system-services= os) #:target-type dmd-root-service-type)) scheme@(guile-user)> ,use(gnu services) scheme@(guile-user)> (length (service-parameters dmds)) $2 =3D 49 scheme@(guile-user)> (define back-edges (dmd-service-back-edges (service-pa= rameters dmds))) scheme@(guile-user)> ,use(srfi srfi-1) scheme@(guile-user)> (map dmd-service-provision (filter (lambda (s) (null? (back-edges s))) (service-parameters dmds))) $3 =3D ((swap-/dev/sda4) (nscd) (guix-daemon) (console-font-tty6) (console-= font-tty5) (console-font-tty4) (console-font-tty3) (console-font-tty2) (con= sole-font-tty1) (ntpd) (elogind) (upower-daemon) (avahi-daemon) (xorg-serve= r) (tor) (ssh-daemon) (bitlbee)) scheme@(guile-user)> (length $3) $4 =3D 17 --8<---------------cut here---------------end--------------->8--- 17 out of 49 services could be restarted. As a first step, we could ignore the other services. As a second step, we could maybe have an =E2=80=98upgrade=E2=80=99 action t= hat would mutate their instance in place, but without actually restarting them, such that the changes would only take effect on the next restart. Roughly, we=E2=80=99d be doing, say: deco upgrade udev /gnu/store/=E2=80=A6-dmd-udev.scm where =E2=80=A6-dmd-udev.scm is the service file that contains: (make #:provides '(udev) =E2=80=A6) The =E2=80=98upgrade=E2=80=99 action would =E2=80=98set!=E2=80=99 all the f= ields of the old service instance to those of the new instance, such that they are =E2=80=98equal?= =E2=80=99 (but not =E2=80=98eq?=E2=80=99.) The caveat is that this is not atomic. Thoughts? The prerequisite to all this work is to make the dmd RPCs machine-processable, which is not too much work. Thanks, Ludo=E2=80=99.