From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 01 08:33:30 2018 Received: (at 22039) by debbugs.gnu.org; 1 Sep 2018 12:33:30 +0000 Received: from localhost ([127.0.0.1]:41268 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fw55m-0008F0-5K for submit@debbugs.gnu.org; Sat, 01 Sep 2018 08:33:30 -0400 Received: from mail-pf1-f182.google.com ([209.85.210.182]:45921) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fw55j-0008El-3J for 22039@debbugs.gnu.org; Sat, 01 Sep 2018 08:33:27 -0400 Received: by mail-pf1-f182.google.com with SMTP id i26-v6so6697658pfo.12 for <22039@debbugs.gnu.org>; Sat, 01 Sep 2018 05:33:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=o6C+XPh6FqZvSnmX4kYnDRb5ljVNiIrqpisJERQKhvs=; b=ZC42zjqgGgWUST1adentBeeCvVjXIkfMyFlvWwOaiYJpcJ/nLf+9HvwJkB+kE8QVvO INC6sS1eQIPzNGuO0C9c/lpqGsRpx9JoTiu9GNoy8jKuEg4gVLQgDw44rH36W2qH2KtG Y7VG3neGJyxzDHENtgga58KpRel0A20nL4UkUTOKIlZ3eHGeN6/pkBGwHKLy8B8K/kyn SZRxUTEjLKdL1SfTqboTaq+ftnzTo06562dBqCAtGNcABijRR9J7/5LGOaTFCPjFgpyP ruZJG1klhCMKSEalYSu7Gh5Cl16Z/GGKfFQAmQTLKHeb4RjAlgL3NlCt5kXOfBxHDhFv bubw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=o6C+XPh6FqZvSnmX4kYnDRb5ljVNiIrqpisJERQKhvs=; b=OBvFRmEuuvlghL3Xze3d6kz7JvVAbTwWmowf3qlk8ewdq1bYc+Ds++GRjCip5iHh2g GPlqYnq1Ijc8Uj00IsgZwq3HsEmcMsYuBvbVLk64xp/FT0DA4Ii6HwmuEBqQLl0BzBLb ev43zPK9qFu/PdcIYhXEnTzNWDQ4UaatykBD/CtJ5b+lndMEjNaELFb4bp1Z4JWIx24Z IeqWwEorunXw3EbhN7bAUR+RS/FQMWAty7LX+cyhC+0zYnVmofgM8CL8jTISn4p/MXO8 OY+Z6RE/wm49cF6L/5r7Z1K3WUYrNkYx9QYk2CT3IZleTPRpuTZNDDxVgGzgVhDnkviW MO5A== X-Gm-Message-State: APzg51Bqrb4+RAET/NkpDySXjVnYioO0tyVDrk1sc0zDtZNEqUHMqXKw fzGxxerLoX5TH6PzZL0XJ3XultlR X-Google-Smtp-Source: ANB0VdZTAYwv0Q3MPms7ozf/XLUTqQ9GGxhHCr7xJmnzgsCTlmkyRgk/UdXWnOGpOI9D5rZt3ZMwVQ== X-Received: by 2002:a63:fb07:: with SMTP id o7-v6mr18534038pgh.333.1535805201146; Sat, 01 Sep 2018 05:33:21 -0700 (PDT) Received: from pidgey (210-1-202-160-cpe.spintel.net.au. [210.1.202.160]) by smtp.gmail.com with ESMTPSA id v8-v6sm16611024pff.120.2018.09.01.05.33.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 01 Sep 2018 05:33:20 -0700 (PDT) References: <874mg6rsjl.fsf@gnu.org> <87tvnhxr20.fsf@zancanaro.id.au> <87sh2tijb2.fsf@gnu.org> <87va7pza4p.fsf@zancanaro.id.au> User-agent: mu4e 1.0; emacs 26.1 From: Carlo Zancanaro To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: bug#22039: [PATCH] 'guix system reconfigure' must start/restart/stop services In-reply-to: <87va7pza4p.fsf@zancanaro.id.au> Date: Sat, 01 Sep 2018 22:33:14 +1000 Message-ID: <87tvn9z9bp.fsf@zancanaro.id.au> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 22039 Cc: 22039@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; format=flowed On Sat, Sep 01 2018, Carlo Zancanaro wrote: > I'll send through an updated patch once I've cleaned it up a > bit, [ ... ] Updated patch attached. --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-gnu-services-Load-all-services-on-reconfigure-not-ju.patch Content-Transfer-Encoding: quoted-printable From=2047647b767930d16ab5a3b855993daf6ddf98f230 Mon Sep 17 00:00:00 2001 From: Carlo Zancanaro Date: Sun, 26 Aug 2018 21:54:14 +1000 Subject: [PATCH] gnu: services: Load all services on reconfigure, not just stopped ones * doc/guix.texi (Invoking guix system): Document the new behaviour. * gnu/services/shepherd.scm (shepherd-service-upgrade): Return a list of services that need to be restarted to complete their upgrade. * guix/scripts/system.scm (call-with-service-upgrade-info): Rename an inter= nal variable to reflect the change to shepherd-service-upgrade. (upgrade-shepherd-services): Print the names of services that need to be restarted in order to be upgraded. =2D-- doc/guix.texi | 8 ++++---- gnu/services/shepherd.scm | 23 ++++++++--------------- guix/scripts/system.scm | 20 ++++++++++++-------- 3 files changed, 24 insertions(+), 27 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index d2d278df4..421762122 100644 =2D-- a/doc/guix.texi +++ b/doc/guix.texi @@ -33,7 +33,7 @@ Copyright @copyright{} 2016 Alex ter Weele@* Copyright @copyright{} 2017, 2018 Cl=C3=A9ment Lassieur@* Copyright @copyright{} 2017 Mathieu Othacehe@* Copyright @copyright{} 2017 Federico Beffa@* =2DCopyright @copyright{} 2017 Carlo Zancanaro@* +Copyright @copyright{} 2017, 2018 Carlo Zancanaro@* Copyright @copyright{} 2017 Thomas Danckaert@* Copyright @copyright{} 2017 humanitiesNerd@* Copyright @copyright{} 2017 Christopher Allan Webber@* @@ -21143,9 +21143,9 @@ systems already running GuixSD.}. This effects all the configuration specified in @var{file}: user accounts, system services, global package list, setuid programs, etc. The command starts system services specified in @var{file} that are not =2Dcurrently running; if a service is currently running, it does not =2Dattempt to upgrade it since this would not be possible without stopping = it =2Dfirst. +currently running; if a service is currently running this command will +arrange for it to be upgraded the next time it is stopped (eg. by +@code{herd stop X} or @code{herd restart X}). =20 This command creates a new generation whose number is one greater than the current generation (as reported by @command{guix system diff --git a/gnu/services/shepherd.scm b/gnu/services/shepherd.scm index 4cd224984..4c7e72049 100644 =2D-- a/gnu/services/shepherd.scm +++ b/gnu/services/shepherd.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2013, 2014, 2015, 2016, 2018 Ludovic Court=C3=A8s ;;; Copyright =C2=A9 2017 Cl=C3=A9ment Lassieur +;;; Copyright =C2=A9 2018 Carlo Zancanaro ;;; ;;; This file is part of GNU Guix. ;;; @@ -329,7 +330,7 @@ symbols provided/required by a service." (define (shepherd-service-upgrade live target) "Return two values: the subset of LIVE (a list of ) that n= eeds to be unloaded, and the subset of TARGET (a list of ) th= at =2Dneeds to be loaded." +need to be restarted to complete their upgrade." (define (essential? service) (memq (first (live-service-provision service)) '(root shepherd))) @@ -346,12 +347,6 @@ needs to be loaded." (and=3D> (lookup-live (shepherd-service-canonical-name service)) live-service-running)) =20 =2D (define (stopped service) =2D (match (lookup-live (shepherd-service-canonical-name service)) =2D (#f #f) =2D (service (and (not (live-service-running service)) =2D service)))) =2D (define live-service-dependents (shepherd-service-back-edges live #:provision live-service-provision @@ -362,16 +357,14 @@ needs to be loaded." (#f (every obsolete? (live-service-dependents service))) (_ #f))) =20 =2D (define to-load =2D ;; Only load services that are either new or currently stopped. =2D (remove running? target)) + (define to-restart + ;; Restart services that are currently running. + (filter running? target)) =20 (define to-unload =2D ;; Unload services that are (1) no longer required, or (2) are in TO= -LOAD. =2D (remove essential? =2D (append (filter obsolete? live) =2D (filter-map stopped to-load)))) + ;; Unload services that are no longer required. + (remove essential? (filter obsolete? live))) =20 =2D (values to-unload to-load)) + (values to-unload to-restart)) =20 ;;; shepherd.scm ends here diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 69bd05b51..41a348a5b 100644 =2D-- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -310,9 +310,9 @@ names of services to load (upgrade), and the list of na= mes of services to unload." (match (current-services) ((services ...) =2D (let-values (((to-unload to-load) + (let-values (((to-unload to-restart) (shepherd-service-upgrade services new-services))) =2D (mproc to-load + (mproc to-restart (map (compose first live-service-provision) to-unload)))) (#f @@ -335,21 +335,25 @@ bring the system down." ;; Arrange to simply emit a warning if the service upgrade fails. (with-shepherd-error-handling (call-with-service-upgrade-info new-services =2D (lambda (to-load to-unload) + (lambda (to-restart to-unload) (for-each (lambda (unload) (info (G_ "unloading service '~a'...~%") unload) (unload-service unload)) to-unload) =20 (with-monad %store-monad =2D (munless (null? to-load) =2D (let ((to-load-names (map shepherd-service-canonical-name t= o-load)) =2D (to-start (filter shepherd-service-auto-start? t= o-load))) =2D (info (G_ "loading new services:~{ ~a~}...~%") to-load-nam= es) + (munless (null? new-services) + (let ((new-service-names (map shepherd-service-canonical-name= new-services)) + (to-restart-names (map shepherd-service-canonical-name= to-restart)) + (to-start (filter shepherd-service-auto-start?= new-services))) + (info (G_ "loading new services:~{ ~a~}...~%") new-service-n= ames) + (unless (null? to-restart-names) + (format #t (G_ "To complete the upgrade, restart the follo= wing services:~%")) + (for-each (cut format #t "~4t~a~%" <>) to-restart-names)) (mlet %store-monad ((files (mapm %store-monad (compose lower-object shepherd-service-f= ile) =2D to-load))) + new-services))) ;; Here we assume that FILES are exactly those that were c= omputed ;; as part of the derivation that built OS, which is norma= lly the ;; case. =2D-=20 2.18.0 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEE1lpncq7JnOkt+LaeqdyPv9awIbwFAluKhwsACgkQqdyPv9aw IbwcpBAAh5maLOBsraA9/gJfF+wuhrmEo17QmwLwnw+2/dXFg7jsrwnDmk8Ht3qE BKR9kPEiKq1T9BPjv9436VY/OW+CULYMwM/yUsbxG3qarsRnXocL1BGIXVr2Sy6q jpwN9q3TMOVwlgHmXfHPqU2yB/GxeV0vyJUmVUdWeFlHUEnI4Mzzc+TIDxYsPJHL GvZeBR6Af+f5lCJMdgV24YChS7gc7ErrUaKO376Mv7b84BLkZT4ZTnE8DgL4jRjW aIr+oabYkXT6/TT8jjcchFiBx521GDkOUi5SMNLvzNhzLnOCOpkYT+IYL7wfwVN5 RbFw+XfiTeMg+SEAWQEIJqdh/WsK7qIwuWDKgZsQAEUovzAtoJ3LqtyEnvScwJ0W kWTRHRWs2B/WLqvGpR9ul6fInzk9YHYc3uUeFGIQQcgjxCOUQX3ahz4f6Ka32Ho3 l3igjWTelJpiq/GT+s3bWIelK8TdI1jOOb0Tp6dF1S8zeVz5DzXScr35CyCcGJq+ Z2rxBfiU3/LdTs0SkIrYvgm/+9eR8VU1C32ZDLmoAcu8aZQ+eqhGpmLcaL5OEphK tzZ53WJ3Ip5j73mObXE02OdteCo8/guY1pDqnvmw13UWcw7esPKT8Zre/dljb7um qJ3UTe8x9nniTeDMUq1IVs3WbqU+I0IUpoNonl61ZWYTsSBDIYY= =nrFf -----END PGP SIGNATURE----- --==-=-=--