Skip to content

Commit 7b8ce6a

Browse files
author
gau1991
committed
Improved MySQL service check
1 parent f116bd0 commit 7b8ce6a

File tree

1 file changed

+43
-31
lines changed

1 file changed

+43
-31
lines changed

ee/cli/plugins/stack_services.py

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,17 @@ def stop(self):
115115
Log.info(self, "PHP5-FPM is not installed")
116116

117117
if self.app.pargs.mysql:
118-
if (EEVariables.ee_mysql_host is "localhost" and
119-
(EEAptGet.is_installed(self, 'mysql-server') or
120-
EEAptGet.is_installed(self, 'percona-server-server-5.6') or
121-
EEAptGet.is_installed(self, 'mariadb-server'))):
122-
services = services + ['mysql']
123-
else:
124-
Log.warn(self, "Remote MySQL found,"
125-
"Unable to stop MySQL service")
118+
if (EEVariables.ee_mysql_host is "localhost"):
119+
if (EEAptGet.is_installed(self, 'mysql-server') or
120+
EEAptGet.is_installed(self, 'percona-server-server-5.6') or
121+
EEAptGet.is_installed(self, 'mariadb-server')):
122+
services = services + ['mysql']
123+
else:
124+
Log.info(self, "MySQL is not installed")
125+
else:
126+
Log.warn(self, "Remote MySQL found, "
127+
"Unable to check MySQL service status")
128+
126129
if self.app.pargs.postfix:
127130
if EEAptGet.is_installed(self, 'postfix'):
128131
services = services + ['postfix']
@@ -182,14 +185,17 @@ def restart(self):
182185
Log.info(self, "PHP5-FPM is not installed")
183186

184187
if self.app.pargs.mysql:
185-
if (EEVariables.ee_mysql_host is "localhost" and
186-
(EEAptGet.is_installed(self, 'mysql-server') or
187-
EEAptGet.is_installed(self, 'percona-server-server-5.6') or
188-
EEAptGet.is_installed(self, 'mariadb-server'))):
189-
services = services + ['mysql']
190-
else:
191-
Log.warn(self, "Remote MySQL found,"
192-
"Unable to restart MySQL service")
188+
if (EEVariables.ee_mysql_host is "localhost"):
189+
if (EEAptGet.is_installed(self, 'mysql-server') or
190+
EEAptGet.is_installed(self, 'percona-server-server-5.6') or
191+
EEAptGet.is_installed(self, 'mariadb-server')):
192+
services = services + ['mysql']
193+
else:
194+
Log.info(self, "MySQL is not installed")
195+
else:
196+
Log.warn(self, "Remote MySQL found, "
197+
"Unable to check MySQL service status")
198+
193199
if self.app.pargs.postfix:
194200
if EEAptGet.is_installed(self, 'postfix'):
195201
services = services + ['postfix']
@@ -249,14 +255,17 @@ def status(self):
249255
Log.info(self, "PHP5-FPM is not installed")
250256

251257
if self.app.pargs.mysql:
252-
if (EEVariables.ee_mysql_host is "localhost" and
253-
(EEAptGet.is_installed(self, 'mysql-server') or
254-
EEAptGet.is_installed(self, 'percona-server-server-5.6') or
255-
EEAptGet.is_installed(self, 'mariadb-server'))):
256-
services = services + ['mysql']
257-
else:
258-
Log.warn(self, "Remote MySQL found,"
258+
if (EEVariables.ee_mysql_host is "localhost"):
259+
if (EEAptGet.is_installed(self, 'mysql-server') or
260+
EEAptGet.is_installed(self, 'percona-server-server-5.6') or
261+
EEAptGet.is_installed(self, 'mariadb-server')):
262+
services = services + ['mysql']
263+
else:
264+
Log.info(self, "MySQL is not installed")
265+
else:
266+
Log.warn(self, "Remote MySQL found, "
259267
"Unable to check MySQL service status")
268+
260269
if self.app.pargs.postfix:
261270
if EEAptGet.is_installed(self, 'postfix'):
262271
services = services + ['postfix']
@@ -315,14 +324,17 @@ def reload(self):
315324
Log.info(self, "PHP5-FPM is not installed")
316325

317326
if self.app.pargs.mysql:
318-
if (EEVariables.ee_mysql_host is "localhost" and
319-
(EEAptGet.is_installed(self, 'mysql-server') or
320-
EEAptGet.is_installed(self, 'percona-server-server-5.6') or
321-
EEAptGet.is_installed(self, 'mariadb-server'))):
322-
services = services + ['mysql']
323-
else:
324-
Log.warn(self, "Remote MySQL found,"
325-
"Unable to reload MySQL service")
327+
if (EEVariables.ee_mysql_host is "localhost"):
328+
if (EEAptGet.is_installed(self, 'mysql-server') or
329+
EEAptGet.is_installed(self, 'percona-server-server-5.6') or
330+
EEAptGet.is_installed(self, 'mariadb-server')):
331+
services = services + ['mysql']
332+
else:
333+
Log.info(self, "MySQL is not installed")
334+
else:
335+
Log.warn(self, "Remote MySQL found, "
336+
"Unable to check MySQL service status")
337+
326338
if self.app.pargs.postfix:
327339
if EEAptGet.is_installed(self, 'postfix'):
328340
services = services + ['postfix']

0 commit comments

Comments
 (0)