Exemplo n.º 1
0
def bundles_deploy(name):
    """After bundle_up, we have them in /tmp/.
    Now, simply copy them into our client's static/bower_components or node_modules.
    """
    client = fabutils.select_client_cfg(name)
    fabutils.wd(client, CFG)

    if not exists(BOWER_COMPONENTS_REMOTE_DIR):
        print("Error: we can't find the bower components directory in remote /tmp.")
        return

    client_dir = os.path.join(CFG.home, CFG.dir, client.name, CFG.project_name, "static")
    if not exists(client_dir):
        run("mkdir -p {}".format(client_dir))

    run("cp -r {} {}".format(BOWER_COMPONENTS_REMOTE_DIR, client_dir))
Exemplo n.º 2
0
def stop(name):
    """Stop the gunicorn process found in the pid file.
    """
    client = fabutils.select_client_cfg(name)
    with cd(fabutils.wd(client, CFG)):
        if exists(PID_FILE):
            run(CMD_KILL)
            run("rm {}".format(PID_FILE))
Exemplo n.º 3
0
def stop(name):
    """Stop the gunicorn process found in the pid file.
    """
    client = fabutils.select_client_cfg(name)
    with cd(fabutils.wd(client, CFG)):
        if exists(PID_FILE):
            run(CMD_KILL)
            run("rm {}".format(PID_FILE))
Exemplo n.º 4
0
def cmd(cmd, name=None):
    """Run any command to client "name".
    """
    if not name:
        print("Please give a client name.")
    else:
        client = fabutils.select_client_cfg(name)
        with cd(fabutils.wd(client, CFG)):
            with prefix(VENV_ACTIVATE.format(client.name)):
                run(cmd)
Exemplo n.º 5
0
def start(name):
    """Run gunicorn (daemon).

    Read the port in PORT.txt
    """
    client = fabutils.select_client_cfg(name)
    with cd(fabutils.wd(client, CFG)):
        with prefix(VENV_ACTIVATE.format(client.name)):
            gunicorn = GUNICORN.format(project_name=CFG.project_name, url=CFG.url)
            run(gunicorn)
Exemplo n.º 6
0
def cmd(cmd, name=None):
    """Run any command to client "name".
    """
    if not name:
        print("Please give a client name.")
    else:
        client = fabutils.select_client_cfg(name)
        with cd(fabutils.wd(client, CFG)):
            with prefix(VENV_ACTIVATE.format(client.name)):
                run(cmd)
Exemplo n.º 7
0
def bundles_deploy(name):
    """After bundle_up, we have them in /tmp/.
    Now, simply copy them into our client's static/bower_components or node_modules.
    """
    client = fabutils.select_client_cfg(name)
    fabutils.wd(client, CFG)

    if not exists(BOWER_COMPONENTS_REMOTE_DIR):
        print(
            "Error: we can't find the bower components directory in remote /tmp."
        )
        return

    client_dir = os.path.join(CFG.home, CFG.dir, client.name, CFG.project_name,
                              "static")
    if not exists(client_dir):
        run("mkdir -p {}".format(client_dir))

    run("cp -r {} {}".format(BOWER_COMPONENTS_REMOTE_DIR, client_dir))
Exemplo n.º 8
0
def make(cmd, name=None):
    """Run any make command remotevy
    """
    if name:
        client = fabutils.select_client_cfg(name)
        with cd(fabutils.wd(client, CFG)):
            with prefix(VENV_ACTIVATE.format(client.name)):
                run("make {}".format(cmd))

    else:
        print("no client name given")
Exemplo n.º 9
0
def make(cmd, name=None):
    """Run any make command remotevy
    """
    if name:
        client = fabutils.select_client_cfg(name)
        with cd(fabutils.wd(client, CFG)):
            with prefix(VENV_ACTIVATE.format(client.name)):
                run("make {}".format(cmd))

    else:
        print("no client name given")
Exemplo n.º 10
0
def start(name):
    """Run gunicorn (daemon).

    Read the port in PORT.txt
    """
    client = fabutils.select_client_cfg(name)
    with cd(fabutils.wd(client, CFG)):
        with prefix(VENV_ACTIVATE.format(client.name)):
            gunicorn = GUNICORN.format(project_name=CFG.project_name,
                                       url=CFG.url)
            run(gunicorn)
Exemplo n.º 11
0
def dbback(name=None):
    """Copy the db file locally (there), appendding a timestamp, and download it.
    Only for users marked in production in clients.yaml.
    """
    if not name:
        clients = sorted(CFG.clients)

    else:
        clients = [fabutils.select_client_cfg(name)]

    # Only for prod:
    clients = filter(lambda it: it.status == "prod", clients)
    print(
        termcolor.colored(
            "Backup for {} users in prod: {}.".format(
                len(clients), map(lambda it: it.name, clients)), "yellow"))

    for client in clients:
        with cd(fabutils.wd(client, CFG)):
            # Copy locally. Append a timestamp.
            run("cp db.db{,.`date +%Y%m%d-%H%M%S`}")

            # Download
            db_backed = "backup/db-{}-{}.sqlite".format(
                client.name,
                datetime.datetime.now().strftime(DATE_FORMAT))
            cmd = "rsync -av {user}@{url}:/home/{user}/{dir}/{client_name}/{project_name}/{db_name} ./{db_backed}".format(
                user=CFG.user,
                url=CFG.url,
                dir=CFG.dir.strip("/"),
                client_name=client.name,
                project_name=CFG.project_name,
                db_name=CFG.db_name,
                db_backed=db_backed)

            print("Downloading db of user {}".format(
                termcolor.colored("{}".format(client.name), "blue")))
            print(cmd)
            os.system(cmd)
Exemplo n.º 12
0
def dbback(name=None):
    """Copy the db file locally (there), appendding a timestamp, and download it.
    Only for users marked in production in clients.yaml.
    """
    if not name:
        clients = sorted(CFG.clients)

    else:
        clients = [fabutils.select_client_cfg(name)]

    # Only for prod:
    clients = filter(lambda it: it.status == "prod", clients)
    print(termcolor.colored(
        "Backup for {} users in prod: {}.".format(
            len(clients),
            map(lambda it: it.name, clients)),
        "yellow"))

    for client in clients:
        with cd(fabutils.wd(client, CFG)):
            # Copy locally. Append a timestamp.
            run("cp db.db{,.`date +%Y%m%d-%H%M%S`}")

            # Download
            db_backed = "backup/db-{}-{}.sqlite".format(client.name, datetime.datetime.now().strftime(DATE_FORMAT))
            cmd = "rsync -av {user}@{url}:/home/{user}/{dir}/{client_name}/{project_name}/{db_name} ./{db_backed}".format(
                user=CFG.user,
                url=CFG.url,
                dir=CFG.dir.strip("/"),
                client_name=client.name,
                project_name=CFG.project_name,
                db_name=CFG.db_name,
                db_backed=db_backed
            )

            print("Downloading db of user {}".format(termcolor.colored("{}".format(client.name), "blue")))
            print(cmd)
            os.system(cmd)