class DaemonUnitTest(ThreadedDatabaseUnitTest): """ Starts a Vmail Daemon within the test suite. """ def setUp(self): super(DaemonUnitTest, self).setUp() from vmail.client import Client from vmail.daemon.rpcserver import RPCServer, JSONReceiver from vmail.daemon.core import Core from vmail.daemon.qpsmtpd import Qpsmtpd self.rpcserver = RPCServer() self.rpcserver.register_object(Core(None)) self.rpcserver.register_object(Qpsmtpd()) self.rpcserver.add_receiver(JSONReceiver('vmaild.sock')) self.rpcserver.start() gevent.sleep() self.client = Client('vmaild.sock') self.client.connect() def tearDown(self): self.client.disconnect() self.rpcserver.stop() super(DaemonUnitTest, self).tearDown() return
class DaemonUnitTest(ThreadedDatabaseUnitTest): """ Starts a Vmail Daemon within the test suite. """ def setUp(self): super(DaemonUnitTest, self).setUp() from vmail.client import Client from vmail.daemon.rpcserver import RPCServer, JSONReceiver from vmail.daemon.core import Core from vmail.daemon.qpsmtpd import Qpsmtpd this = self class Daemon(object): def __init__(self): self.db_session = this.db_session self.rpcserver = RPCServer() self.rpcserver.register_object(Core(Daemon())) self.rpcserver.register_object(Qpsmtpd()) self.rpcserver.add_receiver(JSONReceiver('vmaild.sock')) self.rpcserver.start() gevent.sleep() self.client = Client('vmaild.sock') self.client.connect() def tearDown(self): self.client.disconnect() self.rpcserver.stop() super(DaemonUnitTest, self).tearDown() return
def __init__(self): self.config = get_config() self.rpcserver = RPCServer() self.core = Core(self) self.rpcserver.add_receiver(JSONReceiver()) self.rpcserver.register_object(self.core) self.rpcserver.register_object(Health()) self.rpcserver.register_object(Qpsmtpd()) self.running = False
def setUp(self): super(DaemonUnitTest, self).setUp() from vmail.client import Client from vmail.daemon.rpcserver import RPCServer, JSONReceiver from vmail.daemon.core import Core from vmail.daemon.qpsmtpd import Qpsmtpd self.rpcserver = RPCServer() self.rpcserver.register_object(Core(None)) self.rpcserver.register_object(Qpsmtpd()) self.rpcserver.add_receiver(JSONReceiver('vmaild.sock')) self.rpcserver.start() gevent.sleep() self.client = Client('vmaild.sock') self.client.connect()
def __init__(self): self.config = get_config() self.rpcserver = RPCServer() self.core = Core(self) self.db_session = init_model() self.rpcserver.add_receiver(JSONReceiver()) self.rpcserver.register_object(self.core) self.rpcserver.register_object(Health()) self.rpcserver.register_object(Qpsmtpd()) self.running = False
def setUp(self): super(DaemonUnitTest, self).setUp() from vmail.client import Client from vmail.daemon.rpcserver import RPCServer, JSONReceiver from vmail.daemon.core import Core from vmail.daemon.qpsmtpd import Qpsmtpd this = self class Daemon(object): def __init__(self): self.db_session = this.db_session self.rpcserver = RPCServer() self.rpcserver.register_object(Core(Daemon())) self.rpcserver.register_object(Qpsmtpd()) self.rpcserver.add_receiver(JSONReceiver('vmaild.sock')) self.rpcserver.start() gevent.sleep() self.client = Client('vmaild.sock') self.client.connect()
def setUp(self): super(DaemonUnitTest, self).setUp() from vmail.client import Client from vmail.daemon.rpcserver import RPCServer, JSONReceiver from vmail.daemon.core import Core from vmail.daemon.qpsmtpd import Qpsmtpd this = self class Daemon(object): def __init__(self): self.db_session = this.db_session self.rpcserver = RPCServer() self.rpcserver.register_object(Core(Daemon())) self.rpcserver.register_object(Qpsmtpd()) self.rpcserver.add_receiver(JSONReceiver('vmaild.sock')) self.rpcserver.start() gevent.sleep() self.client = Client('vmaild.sock') self.client.connect()
class Daemon(object): def __init__(self): self.config = get_config() self.rpcserver = RPCServer() self.core = Core(self) self.rpcserver.add_receiver(JSONReceiver()) self.rpcserver.register_object(self.core) self.rpcserver.register_object(Health()) self.rpcserver.register_object(Qpsmtpd()) self.running = False def start(self): # Get the uid and gid we want to run as try: gid = grp.getgrnam(self.config['group']).gr_gid except KeyError: log.fatal("Cannot find group '%s'", self.config['group']) return 1 try: uid = pwd.getpwnam(self.config['user']).pw_uid except KeyError: log.fatal("Cannot find user '%s'", self.config['user']) return 1 # Relinquish our root privileges os.setgid(gid) os.setuid(uid) # Setup database connections connect() rw_connect() # Start the RPC server self.rpcserver.start() # Start this greenlet blocking self.running = True while self.running: gevent.sleep(0.1) def stop(self): self.running = False self.rpcserver.stop()
class Daemon(object): def __init__(self): self.config = get_config() self.rpcserver = RPCServer() self.core = Core(self) self.db_session = init_model() self.rpcserver.add_receiver(JSONReceiver()) self.rpcserver.register_object(self.core) self.rpcserver.register_object(Health()) self.rpcserver.register_object(Qpsmtpd()) self.running = False def start(self): # Get the uid and gid we want to run as try: gid = grp.getgrnam(self.config['group']).gr_gid except KeyError: log.fatal("Cannot find group '%s'", self.config['group']) return 1 try: uid = pwd.getpwnam(self.config['user']).pw_uid except KeyError: log.fatal("Cannot find user '%s'", self.config['user']) return 1 # Relinquish our root privileges os.setgid(gid) os.setuid(uid) # Start the RPC server self.rpcserver.start() # Start this greenlet blocking self.running = True while self.running: gevent.sleep(0.1) def stop(self): self.running = False self.rpcserver.stop()