Skip to content
forked from Simple2B/babybots

Flask Server for scheduling and run scrapping script

Notifications You must be signed in to change notification settings

Erko21/babybots

 
 

Repository files navigation

Instruction for deploy application

How to push and update on AWS

  1. Make some changes and push them to github
  2. Go to AWS by ssh
ssh -i <<path to babybots.cer>> ec2-user@ec2-34-229-136-66.compute-1.amazonaws.com
  1. Go to project folder
cd babybots
  1. Now you need to restart the server. Please use commands:
docker-compose down; docker-compose up --build -d

— possible in single line

  1. Run next commands:
git fetch
git pull

NOTE: Make sure that the branch you push to is the same that you pull from.

All script run logs will be in files:

  • run-script.out
  • run-script.err

How to get web application logs?

  • use docker-compose command:
docker-compose logs -f

Deploy from github

Choice or create folder for deploy. Go to the project folder and and download the project from GitHub here:

cd ~/project_folder
git clone https://github.com/Simple2B/babybots.git .

Prepare python virtual environment

Open a project and create python virtual environment:

cd ~/project_folder
python3 -m virtualenv .venv
source .venv/bin/activate
pip install -r requirements.txt

Create .env file

In the project folder need create file .env with next context:

SECRET_KEY=<<secret-key-string>>

ADMIN_USER_NAME=admin
ADMIN_USER_PASS=1234

NOTE: Please put here default admin credentials. Also you need to choose SECRET_KEY.

Prepare database

Execute following lines under virtual environment

flask drob-db
flask create-db

Docker

To start docker container:

sudo systemctl enable docker
sudo systemctl start docker

To build and run docker container:

docker-compose up --build -d

After changing in project you need to restart docker:

docker-compose down
docker-compose up --build -d

Crontab

Crontab run script every minute

crontab -e

Write to file:

* * * * *  path to run-script.sh

Read file:

crontab -l

NGINX configuration

server {
    server_name <<your DNS server name>>;
    location / {
      proxy_pass http://localhost:5000;
    }

    listen 80;
}

About

Flask Server for scheduling and run scrapping script

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 98.2%
  • Other 1.8%