# -*- coding: utf-8 -*- import rpc class Methods(object): def uptime(self, msg): return "Hello " + msg def hello(self): ok = "LOL" return ok if __name__ == '__main__': myserver = rpc.Server(Methods(), identity='worker2') myserver.run()
import os import logging import rpc from context import lab_channel, lab_logging os.system('cls') lab_logging.setup(stream_level=logging.INFO) logger = logging.getLogger('vs2lab.lab2.rpc.runsrv') chan = lab_channel.Channel() chan.channel.flushall() logger.debug('Flushed all redis keys.') srv = rpc.Server() srv.run()
import sys print sys.argv ism = "m" in sys.argv isa = "a" in sys.argv isb = "b" in sys.argv import rpc import tcp host, port = "127.0.0.1", 10471 reg_port = port + 1 if ism: port = reg_port reg = Registor() rs = rpc.Server(host, port) rs.add_service("reg", reg) if isa: port += 2 class A(object): def a(self): return "a" a1 = A() a2 = A() rs = rpc.Server(host, port) rs.add_service("ra1", a1) rs.add_service("ra2", a2)