def awaken(app, databaseurl): """Restore the database from a given url.""" id = app config = get_config() config.load() bucket = data.user_s3_bucket() key = bucket.lookup('{}.dump'.format(id)) url = key.generate_url(expires_in=300) heroku_app = HerokuApp(id, output=None, team=None) heroku_app.addon("heroku-postgresql:{}".format( config.get('database_size'))) time.sleep(60) heroku_app.pg_wait() time.sleep(10) heroku_app.addon("heroku-redis:premium-0") heroku_app.restore(url) # Scale up the dynos. log("Scaling up the dynos...") size = config.get("dyno_type") for process in ["web", "worker"]: qty = config.get("num_dynos_" + process) heroku_app.scale_up_dyno(process, qty, size) if config.get("clock_on"): heroku_app.scale_up_dyno("clock", 1, size)
def awaken(app, databaseurl): """Restore the database from a given url.""" id = app config = get_config() config.load_config() database_size = config.get('database_size') subprocess.check_call( "heroku addons:create heroku-postgresql:{} --app {}".format( database_size, app_name(id)), shell=True) subprocess.check_call("heroku pg:wait --app {}".format(app_name(id)), shell=True) bucket = data.user_s3_bucket() key = bucket.lookup('{}.dump'.format(id)) url = key.generate_url(expires_in=300) cmd = "heroku pg:backups restore" subprocess.check_call("{} '{}' DATABASE_URL --app {} --confirm {}".format( cmd, url, app_name(id), app_name(id)), shell=True) subprocess.check_call( "heroku addons:create heroku-redis:premium-0 --app {}".format( app_name(id)), shell=True) # Scale up the dynos. log("Scaling up the dynos...") scale_up_dynos(app_name(id))
def awaken(app, databaseurl): """Restore the database from a given url.""" id = app config = get_config() config.load() subprocess.check_call([ "heroku", "addons:create", "heroku-postgresql:{}".format(config.get('database_size')), "--app", app_name(id), ]) bucket = data.user_s3_bucket() key = bucket.lookup('{}.dump'.format(id)) url = key.generate_url(expires_in=300) time.sleep(60) subprocess.check_call(["heroku", "pg:wait", "--app", app_name(id)]) time.sleep(10) subprocess.check_call([ "heroku", "addons:create", "heroku-redis:premium-0", "--app", app_name(id) ]) subprocess.check_call([ "heroku", "pg:backups:restore", "{}".format(url), "DATABASE_URL", "--app", app_name(id), "--confirm", app_name(id), ]) # Scale up the dynos. log("Scaling up the dynos...") heroku.scale_up_dynos(app_name(id))