Exemple #1
0
def main(argv):
    service_objs = []
    for name, conf in SERVICES.items():
        service_objs.append(Service(name, **conf))
    deploy(service_objs, stop="stop" in argv, quick="--quick" in argv)
Exemple #2
0
            raise Exception("Template paths must end with .template")
        self.filename = filename

    def render(self, service):
        context = service.get_default_context()

        full_path = os.path.join(context['project_dir'], self.filename)
        templated_path = os.path.splitext(full_path)[0]

        contents = open(full_path).read().decode("utf8")
        contents = contents.format(**context)
        open(templated_path, "w").write(contents.encode("utf8"))
        return templated_path

def deploy(services, stop=False):
    for service in services:
        if stop:
            if service.is_running():
                service.stop()
        elif service.is_running():
            service.restart()
        else:
            service.start()

if __name__ == "__main__":
    import sys
    service_objs = []
    for name, conf in SERVICES.items():
        service_objs.append(Service(name, **conf))
    deploy(service_objs, stop="stop" in sys.argv)