bleib 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/bleib/configuration.rb +1 -1
- data/lib/bleib/database.rb +28 -16
- data/lib/bleib/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0026c9589d77a8763ca098abe295bfbe5bffde917753aab9a32c2743648cab3
|
4
|
+
data.tar.gz: 79a70f7065aa9e5a34a941eb371275c5c442f1a46f27d6e1c4d67c2beab83c3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cf13688c65d9cbc2a88255c00029fdbf67febd13b6a07888954f95ed87db11a52a8712fc369434926d7c3a455235418f92762d627fde845408e660672a8dbeb
|
7
|
+
data.tar.gz: 221c1440dcc7249edcf5de75734a53f4a8165aafbdc3b9cd08eb41a5a9dff268ac2417b60f95226b9668c0568e476d730157c3ca9aa396ee7b85b0a75ce3536c
|
data/lib/bleib/configuration.rb
CHANGED
@@ -9,7 +9,7 @@ module Bleib
|
|
9
9
|
DEFAULT_CHECK_MIGRATIONS_INTERVAL = 5 # Seconds
|
10
10
|
DEFAULT_DATABASE_YML_PATH = 'config/database'
|
11
11
|
|
12
|
-
SUPPORTED_ADAPTERS = %w(postgresql postgis)
|
12
|
+
SUPPORTED_ADAPTERS = %w(postgresql postgis mysql2)
|
13
13
|
|
14
14
|
def self.from_environment
|
15
15
|
check_database_interval = interval_or_default(
|
data/lib/bleib/database.rb
CHANGED
@@ -40,26 +40,38 @@ module Bleib
|
|
40
40
|
logger.debug('Database check succeeded')
|
41
41
|
|
42
42
|
false
|
43
|
-
rescue
|
44
|
-
|
45
|
-
# PG::ConnectionBad: could not connect to server: Connection refused
|
46
|
-
# Is the server running on host "127.0.0.1" and accepting
|
47
|
-
# TCP/IP connections on port 5432?
|
48
|
-
# On wrong/missing user:
|
49
|
-
# PG::ConnectionBad: FATAL: password authentication failed for user "wrong"
|
50
|
-
# On wrong password:
|
51
|
-
# PG::ConnectionBad: FATAL: password authentication failed for user "user"
|
43
|
+
rescue Exception => e
|
44
|
+
raise e unless database_down_exception?(e)
|
52
45
|
|
53
46
|
logger.debug("Database check failed: #{e}")
|
54
|
-
|
55
47
|
true
|
56
|
-
|
57
|
-
# On missing database:
|
58
|
-
# ActiveRecord::NoDatabaseError: FATAL: database "wrong" does not exist
|
59
|
-
|
60
|
-
logger.debug("Database check failed: #{e}")
|
48
|
+
end
|
61
49
|
|
62
|
-
|
50
|
+
def database_down_exception?(exception)
|
51
|
+
# Matching by class name because only constants defined by
|
52
|
+
# the used database adapter will be loaded.
|
53
|
+
case exception.class.name
|
54
|
+
when 'PG::ConnectionBad'
|
55
|
+
# On stopped database:
|
56
|
+
# PG::ConnectionBad: could not connect to server: Connection refused
|
57
|
+
# Is the server running on host "127.0.0.1" and accepting
|
58
|
+
# TCP/IP connections on port 5432?
|
59
|
+
# On wrong/missing user/password:
|
60
|
+
# PG::ConnectionBad: FATAL: password authentication failed for user "wrong"
|
61
|
+
true
|
62
|
+
when 'Mysql2::Error'
|
63
|
+
# On stopped database:
|
64
|
+
# Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
|
65
|
+
# On wrong/missing user/password:
|
66
|
+
# Access denied for user 'sraeze'@'localhost' (using password: YES)
|
67
|
+
true
|
68
|
+
when 'ActiveRecord::NoDatabaseError'
|
69
|
+
# On missing database:
|
70
|
+
# ActiveRecord::NoDatabaseError: FATAL: database "wrong" does not exist
|
71
|
+
true
|
72
|
+
else
|
73
|
+
false
|
74
|
+
end
|
63
75
|
end
|
64
76
|
|
65
77
|
def remove_connection
|
data/lib/bleib/version.rb
CHANGED