#!/bin/bash # # functions for setting up app backend ####################################### # creates REDIS db using docker # Arguments: # None ####################################### backend_redis_create() { print_banner printf "${WHITE} 💻 Criando Redis & Banco Postgres...${GRAY_LIGHT}" printf "\n\n" sleep 2 sudo su - root < /home/deploy/${instancia_add}/backend/.env NODE_ENV= BACKEND_URL=${backend_url} FRONTEND_URL=${frontend_url} PROXY_PORT=443 PORT=${backend_port} DB_DIALECT=postgres DB_HOST=localhost DB_PORT=5432 DB_USER=${instancia_add} DB_PASS=${mysql_root_password} DB_NAME=${instancia_add} JWT_SECRET=${jwt_secret} JWT_REFRESH_SECRET=${jwt_refresh_secret} REDIS_URI=redis://:${mysql_root_password}@127.0.0.1:${redis_port} REDIS_OPT_LIMITER_MAX=1 REGIS_OPT_LIMITER_DURATION=3000 USER_LIMIT=${max_user} CONNECTIONS_LIMIT=${max_whats} CLOSED_SEND_BY_ME=true [-]EOF EOF sleep 2 } ####################################### # installs node.js dependencies # Arguments: # None ####################################### backend_node_dependencies() { print_banner printf "${WHITE} 💻 Instalando dependências do backend...${GRAY_LIGHT}" printf "\n\n" sleep 2 sudo su - deploy < /etc/nginx/sites-available/${instancia_add}-backend << 'END' server { server_name $backend_hostname; location / { proxy_pass http://127.0.0.1:${backend_port}; proxy_http_version 1.1; proxy_set_header Upgrade \$http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host \$host; proxy_set_header X-Real-IP \$remote_addr; proxy_set_header X-Forwarded-Proto \$scheme; proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; proxy_cache_bypass \$http_upgrade; } } END ln -s /etc/nginx/sites-available/${instancia_add}-backend /etc/nginx/sites-enabled EOF sleep 2 }