Skip to content

Commit d543db3

Browse files
author
gau1991
committed
Fixes #428
1 parent cf5312c commit d543db3

File tree

1 file changed

+56
-19
lines changed

1 file changed

+56
-19
lines changed

ee/cli/plugins/stack_services.py

Lines changed: 56 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from cement.core import handler, hook
33
from ee.core.services import EEService
44
from ee.core.logging import Log
5+
from ee.core.variables import EEVariables
56

67

78
class EEStackStatusController(CementBaseController):
@@ -28,8 +29,12 @@ def start(self):
2829
Log.debug(self, "php5-fpm service start")
2930
services = services + ['php5-fpm']
3031
if self.app.pargs.mysql:
31-
Log.debug(self, "mysql service start")
32-
services = services + ['mysql']
32+
if EEVariables.ee_mysql_host is "localhost":
33+
Log.debug(self, "mysql service start")
34+
services = services + ['mysql']
35+
else:
36+
Log.warn(self, "Remote MySQL found,"
37+
"unable to start MySQL service")
3338
if self.app.pargs.postfix:
3439
Log.debug(self, "postfix service start")
3540
services = services + ['postfix']
@@ -39,9 +44,13 @@ def start(self):
3944
if self.app.pargs.dovecot:
4045
Log.debug(self, "dovecot service start")
4146
services = services + ['dovecot']
42-
if not services:
43-
Log.debug(self, "nginx,php5-fpm,mysql,postfix services start")
47+
if not services and EEVariables.ee_mysql_host is "localhost":
4448
services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix']
49+
Log.debug(self, "nginx,php5-fpm,mysql,postfix services start")
50+
elif not services:
51+
services = services + ['nginx', 'php5-fpm', 'postfix']
52+
Log.debug(self, "nginx,php5-fpm,postfix services start")
53+
4554
for service in services:
4655
EEService.start_service(self, service)
4756

@@ -56,8 +65,12 @@ def stop(self):
5665
Log.debug(self, "php5-fpm service stop")
5766
services = services + ['php5-fpm']
5867
if self.app.pargs.mysql:
59-
Log.debug(self, "mysql service stop")
60-
services = services + ['mysql']
68+
if EEVariables.ee_mysql_host is "localhost":
69+
Log.debug(self, "mysql service stop")
70+
services = services + ['mysql']
71+
else:
72+
Log.warn(self, "Remote MySQL found, "
73+
"unable to stop MySQL service")
6174
if self.app.pargs.postfix:
6275
Log.debug(self, "postfix service stop")
6376
services = services + ['postfix']
@@ -67,9 +80,12 @@ def stop(self):
6780
if self.app.pargs.dovecot:
6881
Log.debug(self, "dovecot service stop")
6982
services = services + ['dovecot']
70-
if not services:
83+
if not services and EEVariables.ee_mysql_host is "localhost":
7184
services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix']
7285
Log.debug(self, "nginx,php5-fpm,mysql,postfix services stop")
86+
elif not services:
87+
services = services + ['nginx', 'php5-fpm', 'postfix']
88+
Log.debug(self, "nginx,php5-fpm,postfix services stop")
7389
for service in services:
7490
EEService.stop_service(self, service)
7591

@@ -84,8 +100,12 @@ def restart(self):
84100
Log.debug(self, "php5-fpm service restart")
85101
services = services + ['php5-fpm']
86102
if self.app.pargs.mysql:
87-
Log.debug(self, "mysql service restart")
88-
services = services + ['mysql']
103+
if EEVariables.ee_mysql_host is "localhost":
104+
Log.debug(self, "mysql service restart")
105+
services = services + ['mysql']
106+
else:
107+
Log.warn(self, "Remote MySQL found, "
108+
"unable to restart MySQL service")
89109
if self.app.pargs.postfix:
90110
Log.debug(self, "postfix service restart")
91111
services = services + ['postfix']
@@ -95,10 +115,13 @@ def restart(self):
95115
if self.app.pargs.dovecot:
96116
Log.debug(self, "dovecot service restart")
97117
services = services + ['dovecot']
98-
if not services:
118+
if not services and EEVariables.ee_mysql_host is "localhost":
99119
services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix']
100-
for service in services:
101120
Log.debug(self, "nginx,php5-fpm,mysql,postfix services restart")
121+
elif not services:
122+
services = services + ['nginx', 'php5-fpm', 'postfix']
123+
Log.debug(self, "nginx,php5-fpm,postfix services restart")
124+
for service in services:
102125
EEService.restart_service(self, service)
103126

104127
@expose(help="Get stack status")
@@ -112,8 +135,12 @@ def status(self):
112135
Log.debug(self, "php5-fpm service status")
113136
services = services + ['php5-fpm']
114137
if self.app.pargs.mysql:
115-
Log.debug(self, "mysql service status")
116-
services = services + ['mysql']
138+
if EEVariables.ee_mysql_host is "localhost":
139+
Log.debug(self, "mysql service status")
140+
services = services + ['mysql']
141+
else:
142+
Log.warn(self, "Remote MySQL found, "
143+
"unable to get MySQL service status")
117144
if self.app.pargs.postfix:
118145
services = services + ['postfix']
119146
Log.debug(self, "postfix service status")
@@ -123,9 +150,12 @@ def status(self):
123150
if self.app.pargs.dovecot:
124151
Log.debug(self, "dovecot service status")
125152
services = services + ['dovecot']
126-
if not services:
127-
Log.debug(self, "nginx,php5-fpm,mysql,postfix services status")
153+
if not services and EEVariables.ee_mysql_host is "localhost":
128154
services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix']
155+
Log.debug(self, "nginx,php5-fpm,mysql,postfix services status")
156+
elif not services:
157+
services = services + ['nginx', 'php5-fpm', 'postfix']
158+
Log.debug(self, "nginx,php5-fpm,postfix services status")
129159
for service in services:
130160
if EEService.get_service_status(self, service):
131161
Log.info(self, "{0:10}: {1}".format(service, "Running"))
@@ -141,8 +171,12 @@ def reload(self):
141171
Log.debug(self, "php5-fpm service reload")
142172
services = services + ['php5-fpm']
143173
if self.app.pargs.mysql:
144-
Log.debug(self, "mysql service reload")
145-
services = services + ['mysql']
174+
if EEVariables.ee_mysql_host is "localhost":
175+
Log.debug(self, "mysql service reload")
176+
services = services + ['mysql']
177+
else:
178+
Log.warn(self, "Remote MySQL found, "
179+
"unable to remote MySQL service")
146180
if self.app.pargs.postfix:
147181
Log.debug(self, "postfix service reload")
148182
services = services + ['postfix']
@@ -152,8 +186,11 @@ def reload(self):
152186
if self.app.pargs.dovecot:
153187
Log.debug(self, "dovecot service reload")
154188
services = services + ['dovecot']
155-
if not services:
189+
if not services and EEVariables.ee_mysql_host is "localhost":
156190
services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix']
157-
for service in services:
158191
Log.debug(self, "nginx,php5-fpm,mysql,postfix services reload")
192+
elif not services:
193+
services = services + ['nginx', 'php5-fpm', 'postfix']
194+
Log.debug(self, "nginx,php5-fpm,postfix services reload")
195+
for service in services:
159196
EEService.reload_service(self, service)

0 commit comments

Comments
 (0)