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))
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))
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)
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)
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))
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")
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)
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)