from command.default import ManagerDefaultController
from cement.core.controller import expose
from util.config import ServerConfig


class ServerController(ManagerDefaultController):
    class Meta:
        label = 'server'
        description = 'Server management'
        arguments = [
            (['--check'], dict(help='Checks configuration and exits app', action='store_true')),
        ]

    @expose(hide=True)
    def default(self):
        if self.app.pargs.check:
            self.check()

        self.app.args.parse_args(['--help'])

    def check(self):
        ServerConfig()
        exit()

@@ -112,28 +112,82 @@
  import 
-Server
 Config
+uration, ServerConfig%0Afrom util.supervisor import Supervisor
 %0A%0A%0Aclass
@@ -445,190 +445,1256 @@
     
-%5D%0A%0A    @expose(hide=True)%0A    def default(self):%0A        if self.app.pargs.check:%0A            self.check()%0A%0A        self.app.args.parse_args(%5B'--help'%5D)%0A%0A    def check(self):%0A       
+    (%5B'server_ids'%5D, dict(%0A                help='Server id available in servers config file (servers:%3Cid%3E:group)',%0A                action='store',%0A                nargs='*'%0A            ))%0A        %5D%0A%0A    @expose(hide=True)%0A    def default(self):%0A        if self.app.pargs.check:%0A            self.check()%0A%0A        self.app.args.parse_args(%5B'--help'%5D)%0A%0A    @expose(help='Start server %3Cserver_id%3E')%0A    def start(self):%0A        supervisor = Supervisor()%0A        server_config = ServerConfig()%0A%0A        for sid in self.app.pargs.server_ids:%0A            if sid in server_config.servers:%0A                supervisor.ctl(%5B'start', supervisor.process_prefix + sid%5D)%0A            else:%0A                print('Server %25s doesn%5C't exists' %25 str(sid))%0A%0A    @expose(help='Stop server %3Cserver_id%3E')%0A    def stop(self):%0A        supervisor = Supervisor()%0A        server_config = ServerConfig()%0A%0A        for sid in self.app.pargs.server_ids:%0A            if sid in server_config.servers:%0A                supervisor.ctl(%5B'stop', supervisor.process_prefix + sid%5D)%0A            else:%0A                print('Server %25s doesn%5C't exists' %25 str(sid))%0A%0A    @expose(help='Restart server %3Cserver_id%3E')%0A    def restart(self):%0A        supervisor = Supervisor()%0A        server_config =
  Ser
@@ -1705,23 +1705,24 @@
 onfig()%0A
+%0A
         
 exit()%0A
@@ -1718,11 +1718,630 @@
     
-exit()
+for sid in self.app.pargs.server_ids:%0A            if sid in server_config.servers:%0A                supervisor.ctl(%5B'restart', supervisor.process_prefix + sid%5D)%0A            else:%0A                print('Server %25s doesn%5C't exists' %25 str(sid))%0A%0A    @expose(help='Attch server %3Cserver_id%3E')%0A    def attach(self):%0A        supervisor = Supervisor()%0A        server_config = ServerConfig()%0A%0A        for sid in self.app.pargs.server_ids:%0A            if sid in server_config.servers:%0A                supervisor.ctl(%5B'fg', supervisor.process_prefix + sid%5D)%0A            else:%0A                print('Server %25s doesn%5C't exists' %25 str(sid))%0A
 %0A

Add server subcommands