<s> from cement . core . controller import expose <EOL> from qldsmanager . command . default import ManagerDefaultController <EOL> from qldsmanager . util . config import ServerConfig <EOL> from qldsmanager . util . supervisor import Supervisor <EOL> class ServerController ( ManagerDefaultController ) : <EOL> class Meta : <EOL> label = '<STR_LIT>' <EOL> description = '<STR_LIT>' <EOL> arguments = [ <EOL> ( [ '<STR_LIT>' ] , dict ( help = '<STR_LIT>' , action = '<STR_LIT:store_true>' ) ) , <EOL> ( [ '<STR_LIT>' ] , dict ( <EOL> help = '<STR_LIT>' , <EOL> action = '<STR_LIT:store>' , <EOL> nargs = '<STR_LIT:*>' <EOL> ) ) <EOL> ] <EOL> @ expose ( hide = True ) <EOL> def default ( self ) : <EOL> if self . app . pargs . check : <EOL> ServerConfig ( ) <EOL> self . app . args . parse_args ( [ '<STR_LIT>' ] ) <EOL> @ expose ( help = '<STR_LIT>' ) <EOL> def start ( self ) : <EOL> supervisor = Supervisor ( ) <EOL> server_config = ServerConfig ( ) <EOL> for sid in self . app . pargs . server_ids : <EOL> if sid in server_config . servers : <EOL> supervisor . ctl ( [ '<STR_LIT:start>' , supervisor . process_prefix + sid ] ) <EOL> else : <EOL> print ( '<STR_LIT>' % str ( sid ) ) <EOL> exit ( <NUM_LIT:50> ) <EOL> @ expose ( help = '<STR_LIT>' ) <EOL> def stop ( self ) : <EOL> supervisor = Supervisor ( ) <EOL> server_config = ServerConfig ( ) <EOL> for sid in self . app . pargs . server_ids : <EOL> if sid in server_config . servers : <EOL> supervisor . ctl ( [ '<STR_LIT>' , supervisor . process_prefix + sid ] ) <EOL> else : <EOL> print ( '<STR_LIT>' % str ( sid ) ) <EOL> exit ( <NUM_LIT:50> ) <EOL> @ expose ( help = '<STR_LIT>' ) <EOL> def restart ( self ) : <EOL> supervisor = Supervisor ( ) <EOL> server_config = ServerConfig ( ) <EOL> for sid in self . app . pargs . server_ids : <EOL> if sid in server_config . servers : <EOL> supervisor . ctl ( [ '<STR_LIT>' , supervisor . process_prefix + sid ] ) <EOL> else : <EOL> print ( '<STR_LIT>' % str ( sid ) ) <EOL> exit ( <NUM_LIT:50> ) <EOL> @ expose ( help = '<STR_LIT>' ) <EOL> def attach ( self ) : <EOL> supervisor = Supervisor ( ) <EOL> server_config = ServerConfig ( ) <EOL> for sid in self . app . pargs . server_ids : <EOL> if sid in server_config . servers : <EOL> supervisor . ctl ( [ '<STR_LIT>' , supervisor . process_prefix + sid ] ) <EOL> else : <EOL> print ( '<STR_LIT>' % str ( sid ) ) <EOL> exit ( <NUM_LIT:50> ) </s>
