Browse Source

Merge branch 'python' of github.com:rtCamp/easyengine into python

bugfixes
gau1991 10 years ago
parent
commit
d0193422af
  1. 2
      ee/cli/plugins/stack.py
  2. 81
      ee/cli/plugins/stack_services.py
  3. 1
      ee/core/aptget.py
  4. 4
      ee/core/services.py
  5. 5
      ee/core/shellexec.py

2
ee/cli/plugins/stack.py

@ -18,6 +18,7 @@ import shutil
import os
import pwd
import grp
from ee.cli.plugins.stack_services import EEStackStatusController
def ee_stack_hook(app):
@ -373,6 +374,7 @@ class EEStackController(CementBaseController):
def load(app):
# register the plugin class.. this only happens if the plugin is enabled
handler.register(EEStackController)
handler.register(EEStackStatusController)
# register a hook (function) to run after arguments are parsed.
hook.register('post_argument_parsing', ee_stack_hook)

81
ee/cli/plugins/stack_services.py

@ -0,0 +1,81 @@
from cement.core.controller import CementBaseController, expose
from cement.core import handler, hook
from ee.core.services import EEService
class EEStackStatusController(CementBaseController):
class Meta:
label = 'stack_services'
stacked_on = 'stack'
stacked_type = 'embedded'
description = 'stack command manages stack operations'
arguments = [
(['--memcache'],
dict(help='start/stop/restart stack', action='store_true')),
(['--dovecot'],
dict(help='start/stop/restart dovecot', action='store_true')),
]
@expose(help="start stack services")
def start(self):
services = []
if self.app.pargs.nginx:
services = services + ['nginx']
elif self.app.pargs.php:
services = services + ['php5-fpm']
elif self.app.pargs.mysql:
services = services + ['mysql']
elif self.app.pargs.postfix:
services = services + ['postfix']
elif self.app.pargs.memcache:
services = services + ['memcached']
elif self.app.pargs.dovecot:
services = services + ['dovecot']
else:
services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix']
for service in services:
EEService.start_service(service)
@expose(help="stop stack services")
def stop(self):
services = []
if self.app.pargs.nginx:
services = services + ['nginx']
elif self.app.pargs.php:
services = services + ['php5-fpm']
elif self.app.pargs.mysql:
services = services + ['mysql']
elif self.app.pargs.postfix:
services = services + ['postfix']
elif self.app.pargs.memcache:
services = services + ['memcached']
elif self.app.pargs.dovecot:
services = services + ['dovecot']
else:
services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix']
for service in services:
EEService.stop_service(service)
@expose(help="restart stack services")
def restart(self):
services = []
if self.app.pargs.nginx:
services = services + ['nginx']
elif self.app.pargs.php:
services = services + ['php5-fpm']
elif self.app.pargs.mysql:
services = services + ['mysql']
elif self.app.pargs.postfix:
services = services + ['postfix']
elif self.app.pargs.memcache:
services = services + ['memcached']
elif self.app.pargs.dovecot:
services = services + ['dovecot']
else:
services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix']
for service in services:
EEService.restart_service(service)
@expose(help="get stack status")
def status(self):
pass

1
ee/core/aptget.py

@ -1,5 +1,6 @@
"""EasyEngine package installation using apt-get module."""
import apt
import apt_pkg
import sys

4
ee/core/services.py

@ -38,8 +38,8 @@ class EEService():
def restart_service(service_name):
try:
stop_service(service_name)
start_service(service_name)
EEService.stop_service(service_name)
EEService.start_service(service_name)
except OSError as e:
print("Execution failed:", e)

5
ee/core/shellexec.py

@ -13,5 +13,10 @@ class EEShellExec():
def cmd_exec(command):
try:
retcode = subprocess.getstatusoutput(command)
if retcode[0] == 0:
return True
else:
return False
except OSError as e:
print(e)
return False

Loading…
Cancel
Save