View deployment_v3.py
def run_deployment_v3(deployment: Deployment): | |
"""Runs deployment as 'app' user with separate commands passing commands via base64 scripts, | |
with timeouts and possibility to abort deployment""" | |
if deployment.is_aborted: | |
print("deployment is aborted") | |
deployment.log("Deployment was aborted") | |
deployment.status = DEPLOYMENT_STATUS.aborted | |
deployment.save(update_fields=['status', ]) | |
return "Aborted" | |
server = deployment.application.server # type: Server |
View paramiko_long_running_command_non_blocking_output_timeout.py
import paramiko | |
import time | |
from io import StringIO | |
import sys | |
import select | |
def main(): | |
"""Run cat command and tries to cancel it """ | |
ip_address = '52.28.75.66' | |
with open('/Users/k/.ssh/id_rsa', 'r') as f: |
View deployment.py
def run_deployment(deployment: Deployment): | |
"""Runs deployment as 'app' user with separate commands passing commands via base64 scripts""" | |
server = deployment.application.server # type: Server | |
rsa_key = server.user.private_key # type: str | |
deployment.log(f"ran run_deployment_v2 for deployment {deployment.id}") | |
username = 'app' | |
deployment.log(f'??? Connecting to {username}@{server.ip_address}') | |
try: | |
pkey = paramiko.RSAKey.from_private_key(StringIO(rsa_key)) | |
client = paramiko.SSHClient() |
View Dockerfile
FROM python:3.8 | |
SHELL ["/bin/bash", "-c"] | |
ENV PIP_NO_CACHE_DIR off | |
ENV PIP_DISABLE_PIP_VERSION_CHECK on | |
ENV PYTHONUNBUFFERED 1 | |
ENV PYTHONDONTWRITEBYTECODE 0 | |
WORKDIR /code/ | |
COPY ./code/requirements.txt /code/ | |
RUN pip install -r requirements.txt | |
COPY ./code/ /code/ |
View Dockerfile
FROM pypy:3 | |
SHELL ["/bin/bash", "-c"] | |
ENV PIP_NO_CACHE_DIR off | |
ENV PIP_DISABLE_PIP_VERSION_CHECK on | |
ENV PYTHONUNBUFFERED 1 | |
ENV PYTHONDONTWRITEBYTECODE 0 | |
RUN apt-get update \ | |
&& apt-get install -y --force-yes \ | |
nano python-pip gettext chrpath libssl-dev libxft-dev \ | |
libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev\ |
View Dockerfile
FROM python:3.8 | |
SHELL ["/bin/bash", "-c"] | |
ENV PIP_NO_CACHE_DIR off | |
ENV PIP_DISABLE_PIP_VERSION_CHECK on | |
ENV PYTHONUNBUFFERED 1 | |
ENV PYTHONDONTWRITEBYTECODE 0 | |
RUN apt-get update \ | |
&& apt-get install -y --force-yes \ | |
nano python-pip gettext chrpath libssl-dev libxft-dev \ | |
libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev\ |
View Dockerfile
FROM python:3.8 | |
SHELL ["/bin/bash", "-c"] | |
ENV PIP_NO_CACHE_DIR off | |
ENV PIP_DISABLE_PIP_VERSION_CHECK on | |
ENV PYTHONUNBUFFERED 1 | |
ENV PYTHONDONTWRITEBYTECODE 0 | |
RUN apt-get update \ | |
&& apt-get install -y --force-yes \ | |
nano python-pip gettext chrpath libssl-dev libxft-dev \ | |
libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev\ |
View Dockerfile
FROM python:3.8 | |
SHELL ["/bin/bash", "-c"] | |
ENV PIP_NO_CACHE_DIR off | |
ENV PIP_DISABLE_PIP_VERSION_CHECK on | |
ENV PYTHONUNBUFFERED 1 | |
ENV PYTHONDONTWRITEBYTECODE 0 | |
RUN apt-get update \ | |
&& apt-get install -y --force-yes \ | |
nano python-pip gettext chrpath libssl-dev libxft-dev \ | |
libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev\ |
View settings.py
REDIS_URL = os.getenv('REDIS_URL', 'redis://localhost:6379') | |
CACHES = { | |
"redis": { | |
"BACKEND": "django_redis.cache.RedisCache", | |
"LOCATION": REDIS_URL, | |
"OPTIONS": { | |
"CLIENT_CLASS": "django_redis.client.DefaultClient", | |
} | |
}, | |
"default": { |
View server_setup.py
def server_setup(server_id: int): | |
"""Connects to server and runs installation of required software""" | |
server = Server.objects.get(pk=server_id) | |
server.setup_status = SETUP_STATUS.started | |
server.save(update_fields=['setup_status', ]) | |
rsa_key = server.user.private_key | |
print(f"ran server_setup server_id={server_id}") | |
setup_command = "curl -sSL https://app.appliku.com/server_api/initial_installation.sh | bash" | |
try: | |
pkey = paramiko.RSAKey.from_private_key(StringIO(rsa_key)) |
NewerOlder