summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Mysql.hs
diff options
context:
space:
mode:
authorNicolas Schodet2019-03-25 21:35:59 +0100
committerNicolas Schodet2019-03-26 00:26:08 +0100
commit7efb5603f6fd4f099d76cd4c01524af7bdac648e (patch)
treee04d4c12fb01fb922eddaaa9551003a1f4013dbd /src/Propellor/Property/Mysql.hs
parent266ad363935a9156aab3289ef8010d2ef0fc98e5 (diff)
Mysql: wait for server to be started
Diffstat (limited to 'src/Propellor/Property/Mysql.hs')
-rw-r--r--src/Propellor/Property/Mysql.hs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Propellor/Property/Mysql.hs b/src/Propellor/Property/Mysql.hs
index 37f0d28b..73d4f62a 100644
--- a/src/Propellor/Property/Mysql.hs
+++ b/src/Propellor/Property/Mysql.hs
@@ -11,6 +11,7 @@ module Propellor.Property.Mysql (
basicPrivileges,
basicStructurePrivileges,
installed,
+ installedAndReady,
databaseExists,
userGrantedOnDatabase,
userGranted,
@@ -97,6 +98,13 @@ installed = install <!> remove
remove = Apt.removed server
server = ["default-mysql-server"]
+-- | Make sure a server is installed and ready.
+installedAndReady :: Property DebianLike
+installedAndReady = ready `requires` installed
+ where
+ ready = scriptProperty ["mysqladmin -w3 ping > /dev/null"]
+ `assume` NoChange
+
-- | Check whether server is installed.
isInstalled :: IO Bool
isInstalled = Apt.isInstalled server
@@ -110,7 +118,7 @@ databaseExists (Database dbname) =
setup <!> cleanup
where
setup :: Property DebianLike
- setup = setup' `requires` installed
+ setup = setup' `requires` installedAndReady
cleanup :: Property UnixLike
cleanup = check isInstalled $ cleanup'
@@ -209,7 +217,7 @@ userGranted' (User username) privs context setupDesc setupSql userGrants =
setup <!> cleanup
where
setup :: Property (HasInfo + DebianLike)
- setup = setup' `requires` installed
+ setup = setup' `requires` installedAndReady
cleanup :: Property UnixLike
cleanup = check isInstalled $ cleanup'