guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

07/10: services: mysql-upgrade: Support custom datadir.


From: guix-commits
Subject: 07/10: services: mysql-upgrade: Support custom datadir.
Date: Sun, 20 Nov 2022 11:56:25 -0500 (EST)

mbakke pushed a commit to branch master
in repository guix.

commit 6ac97bb5035ae10ed8ae39b7dbfbf60030dad4d8
Author: Marius Bakke <marius@gnu.org>
AuthorDate: Sat Oct 29 18:18:43 2022 +0200

    services: mysql-upgrade: Support custom datadir.
    
    * gnu/services/databases.scm (mysql-upgrade-wrapper): Take service
    configuration as argument, and pass the config file to mysql_upgrade.
    (mysql-upgrade-shepherd-service): Pass CONFIG instead of just socket and
    executable to MYSQL-UPGRADE-WRAPPER.
---
 gnu/services/databases.scm | 61 +++++++++++++++++++++++-----------------------
 1 file changed, 31 insertions(+), 30 deletions(-)

diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm
index cc9379792d..96504a27ea 100644
--- a/gnu/services/databases.scm
+++ b/gnu/services/databases.scm
@@ -6,7 +6,7 @@
 ;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org>
 ;;; Copyright © 2018 Julien Lepiller <julien@lepiller.eu>
 ;;; Copyright © 2019 Robert Vollmert <rob@vllmrt.net>
-;;; Copyright © 2020 Marius Bakke <marius@gnu.org>
+;;; Copyright © 2020, 2022 Marius Bakke <marius@gnu.org>
 ;;; Copyright © 2021 David Larsson <david.larsson@selfhosted.xyz>
 ;;; Copyright © 2021 Aljosha Papsch <ep@stern-data.com>
 ;;;
@@ -678,33 +678,36 @@ FLUSH PRIVILEGES;
                    (list #$(mysql-install config))
                    #:log-file "/var/log/mysqld-install.log")))))
 
-(define (mysql-upgrade-wrapper mysql socket-file)
+(define (mysql-upgrade-wrapper config)
   ;; The MySQL socket and PID file may appear before the server is ready to
   ;; accept connections.  Ensure the socket is responsive before attempting
   ;; to run the upgrade script.
-  (program-file
-   "mysql-upgrade-wrapper"
-   #~(begin
-       (let ((mysql-upgrade #$(file-append mysql "/bin/mysql_upgrade"))
-             (timeout 20))
-         (begin
-           (let loop ((i 0))
-             (catch 'system-error
-               (lambda ()
-                 (let ((sock (socket PF_UNIX SOCK_STREAM 0)))
-                   (connect sock AF_UNIX #$socket-file)
-                   (close-port sock)
-                   ;; The socket is ready!
-                   (execl mysql-upgrade mysql-upgrade
-                          (string-append "--socket=" #$socket-file))))
-               (lambda args
-                 (if (< i timeout)
-                     (begin
-                       (sleep 1)
-                       (loop (+ 1 i)))
-                     ;; No luck, give up.
-                     (throw 'timeout-error
-                            "MySQL server did not appear in time!"))))))))))
+  (let ((mysql (mysql-configuration-mysql config))
+        (socket-file (mysql-configuration-socket config))
+        (config-file (mysql-configuration-file config)))
+    (program-file
+     "mysql-upgrade-wrapper"
+     #~(begin
+         (let ((mysql-upgrade #$(file-append mysql "/bin/mysql_upgrade"))
+               (timeout 20))
+           (begin
+             (let loop ((i 0))
+               (catch 'system-error
+                 (lambda ()
+                   (let ((sock (socket PF_UNIX SOCK_STREAM 0)))
+                     (connect sock AF_UNIX #$socket-file)
+                     (close-port sock)
+                     ;; The socket is ready!
+                     (execl mysql-upgrade mysql-upgrade
+                            (string-append "--defaults-file=" #$config-file))))
+                 (lambda args
+                   (if (< i timeout)
+                       (begin
+                         (sleep 1)
+                         (loop (+ 1 i)))
+                       ;; No luck, give up.
+                       (throw 'timeout-error
+                              "MySQL server did not appear in time!")))))))))))
 
 (define (mysql-upgrade-shepherd-service config)
   (list (shepherd-service
@@ -712,11 +715,9 @@ FLUSH PRIVILEGES;
          (requirement '(mysql))
          (one-shot? #t)
          (documentation "Upgrade MySQL database schemas.")
-         (start (let ((mysql (mysql-configuration-mysql config))
-                      (socket (mysql-configuration-socket config)))
-                  #~(make-forkexec-constructor
-                     (list #$(mysql-upgrade-wrapper mysql socket))
-                     #:user "mysql" #:group "mysql"))))))
+         (start #~(make-forkexec-constructor
+                   (list #$(mysql-upgrade-wrapper config))
+                   #:user "mysql" #:group "mysql")))))
 
 
 (define (mysql-shepherd-services config)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]