Beispiel #1
0
Datei: oand.py Projekt: oan/oand
    def handle_network(self, action):
        config = {}
        app = {}
        daemon = {}

        for x in range(10):
            x = int(x)
            print "%s daemon %d" % (action, x)
            if x == 0:
                config[x] = Config(
                  "server-" + str(x),
                  "localhost",
                  str(4000 + x)
                )
            else:
                config[x] = Config(
                  "server-" + str(x),
                  "localhost",
                  str(4000 + x),
                  "server-" + str(x-1),
                  "localhost",
                  str(4000 + x - 1)
                )

            config[x].pid_file = "/tmp/oand-%d.pid" % x
            config[x].log_file = "../log/oand-network.log"

            app[x] = OANApplication.create_twisted_circular_node(config[x])
            daemon[x] = OANDaemon(app[x])
            if (action == "start"):
                daemon[x].start()
                time.sleep(1)
            elif (action == "stop"):
                daemon[x].stop()