def setup_settings_local(self): line = "\nfrom settings_local import *\n" append("settings.py", line) context = { "db_name": "{0}".format(self.db_name), "db_user": "******".format(config.get("postgres_user", self.app_name)), "db_pass": "******".format(config.get("postgres_password", self.app_name)), "db_host": "localhost", "db_port": "", } upload_template("templates/settings_local.conf", "settings_local.py", context, overwrite=True)
def setup_gunicorn_supervisor(self): context = { "app_name": self.app_name, "app_package": self.app_package, "gunicorn_port": config.get("gunicorn_port", 8000), "user": config.get("user", "root") } upload_template("templates/gunicorn_supervisor.conf", "/etc/supervisor/conf.d/{0}_gunicorn.conf".format(self.app_name), context=context, overwrite=True) run("supervisorctl reread") run("supervisorctl update") run("supervisorctl restart {0}_gunicorn".format(self.app_name))
def add_webserver_virtual_host(self): """ Uploads the virtual host template and restart nginx to update the config """ context = { "app": self.app_name, "gunicorn_port": config.get("gunicorn_port", 8000), "server_port": config.get("server_port", 80) } server_name = config.get("server_name") if server_name: context["server_name"] = "server_name {0};".format(server_name) upload_template("templates/nginx_vhost.conf", "/etc/nginx/sites-available/{0}.conf".format(self.app_name), context=context, overwrite=True) with settings(warn_only=True): run("rm /etc/nginx/sites-enabled/default") run("rm /etc/nginx/sites-enabled/{0}.conf".format(self.app_name)) run("ln -s /etc/nginx/sites-available/{app}.conf /etc/nginx/sites-enabled/{app}.conf".format(app=self.app_name)) run("service nginx restart")