예제 #1
0
    def execute_yay(self, stream):
        """
        Takes a stream containing tasks encoded as Yay and executes them.

        Returns an object implementing ITask for tracking execution of
        the tasks.
        """
        d = yay.load(stream)
        p = ParallelTask(TaskType.create_all(d["tasks"]))
        self.tasks.add(p)
        return p
예제 #2
0
def run(config_filename):
    if len(sys.argv) != 2:
        usage()
        return 255
    config = yay.load(open(config_filename).read())
    pidfile = config["pidfile"]
    logfile = config["logfile"]
    command = sys.argv[1]
    if command == "start":
        # we pass arguments through to the tac file using the environment
        # because there is no other option
        os.environ["LOGTAIL_CONFIG_FILENAME"] = config_filename
        sys.argv[1:] = ["-y", sibpath(__file__, "logtail.tac"), "--pidfile", pidfile, "--logfile", logfile]
        twistd_run()
    elif command == "stop":
        try:
            pid = int(open(pidfile).read())
        except IOError:
            print "Logtail is not running"
            return 255
        os.kill(pid, 15)
    else:
        usage()
        return 255