Browse Source

enabled logging

bugfixes
harshadyeola 10 years ago
parent
commit
9f818ee227
  1. 4
      ee/cli/main.py
  2. 8
      ee/cli/plugins/stack_services.py
  3. 16
      ee/core/services.py

4
ee/cli/main.py

@ -24,8 +24,8 @@ class EEApp(foundation.CementApp):
label = 'ee' label = 'ee'
# Log writing to file # Log writing to file
# defaults = init_defaults('ee', 'log.logging') defaults = init_defaults('ee', 'log.logging')
# defaults['log.logging']['file'] = '/tmp/my.log' defaults['log.logging']['file'] = '/tmp/my.log'
config_defaults = defaults config_defaults = defaults

8
ee/cli/plugins/stack_services.py

@ -34,7 +34,7 @@ class EEStackStatusController(CementBaseController):
else: else:
services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix']
for service in services: for service in services:
EEService.start_service(service) EEService.start_service(self, service)
@expose(help="stop stack services") @expose(help="stop stack services")
def stop(self): def stop(self):
@ -54,7 +54,7 @@ class EEStackStatusController(CementBaseController):
else: else:
services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix']
for service in services: for service in services:
EEService.stop_service(service) EEService.stop_service(self, service)
@expose(help="restart stack services") @expose(help="restart stack services")
def restart(self): def restart(self):
@ -74,7 +74,7 @@ class EEStackStatusController(CementBaseController):
else: else:
services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix']
for service in services: for service in services:
EEService.restart_service(service) EEService.restart_service(self, service)
@expose(help="get stack status") @expose(help="get stack status")
def status(self): def status(self):
@ -94,5 +94,5 @@ class EEStackStatusController(CementBaseController):
else: else:
services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix']
for service in services: for service in services:
if EEService.get_service_status(service): if EEService.get_service_status(self, service):
print("{0}: Running".format(service)) print("{0}: Running".format(service))

16
ee/core/services.py

@ -11,19 +11,19 @@ class EEService():
# TODO method for services # TODO method for services
pass pass
def start_service(service_name): def start_service(self, service_name):
try: try:
retcode = subprocess.getstatusoutput('service {0} start' retcode = subprocess.getstatusoutput('service {0} start'
.format(service_name)) .format(service_name))
if retcode[0] == 0: if retcode[0] == 0:
print("Started : {0}".format(service_name)) print("Started : {0}".format(service_name))
else: else:
print(retcode[1]) self.app.log.error(retcode[1])
except OSError as e: except OSError as e:
print("Execution failed:", e) self.app.log.error("Execution failed:", e)
return False return False
def stop_service(service_name): def stop_service(self, service_name):
try: try:
retcode = subprocess.getstatusoutput('service {0} stop' retcode = subprocess.getstatusoutput('service {0} stop'
.format(service_name)) .format(service_name))
@ -33,17 +33,17 @@ class EEService():
else: else:
return False return False
except OSError as e: except OSError as e:
print("Execution failed:", e) self.app.log.error("Execution failed:", e)
return False return False
def restart_service(service_name): def restart_service(self, service_name):
try: try:
EEService.stop_service(service_name) EEService.stop_service(service_name)
EEService.start_service(service_name) EEService.start_service(service_name)
except OSError as e: except OSError as e:
print("Execution failed:", e) self.app.log.error("Execution failed:", e)
def get_service_status(service_name): def get_service_status(self, service_name):
try: try:
is_exist = subprocess.getstatusoutput('which {0}' is_exist = subprocess.getstatusoutput('which {0}'
.format(service_name))[0] .format(service_name))[0]

Loading…
Cancel
Save