etkeys / videodl

A simple web app for family to download videos from the web (think vlogs for offline viewing).
MIT License
0 stars 0 forks source link

videodl

A simple web app for family to download videos from the web (think vlogs for offline viewing).

Development

Running the dev database

If you just need to start postgres container:

docker compose -f postgres/compose.yml up --detach

If you need to rebuild the dev database (postgres container will be started automatically):

cd src
./init_db_dev.sh

Installing Docker

Use docker for Postgresql.

  1. Verify if docker is already installed

    sudo docker run hello-world
  2. You should get a message that indicates Docker is installed correctly. If not, follow instructions to install Docker.

Connecting to the dev database

The postgres container has an application specific database called "videodl". This database is in addition to the standard "postgres" default database. To connect to the "videodl" database execute the following:

docker exec -it videodl-db psql -U postgres -d videodl

Running the app

NOTE: The dev database should be initialized and running first.

cd src
python3 app.py

Running the worker

NOTE: The dev database should be initialized and running first.

cd src
python3 worker_run.py

Deploying

NOTE: The Github Actions workflow will package the application files, support files, and configuration files into a single tar file. The tar file will then be copied to an ftp server.

  1. Copy the tar file from the ftp server to the deploy server.

  2. Stop the services that run the application. This is needed so the application files can be safely replaced.

    sudo systemctl stop videodl_worker.service
    sudo systemctl stop videodl.service
  3. cd into the directory that contains all the application files.

  4. Delete all the files in the directory

    rm -rf *
  5. Copy the tar file that was copied from the FTP server to the current directory.

  6. Unpack the tar file

    tar xvfz <tar_file>
  7. If the systemd service files have been updated:

    1. Copy the service files to /usr/local/lib/systemd/system/.

    2. Reload the systemd daemon to pickup the new changes.

      sudo systemctl daemon-reload
  8. Create a new python virtual environment.

    python3 -m venv venv
  9. Activate the python virtual environment.

    source venv/bin/activate
  10. Install package dependencies

    pip install -r requirements.txt
  11. If the application database needs to be upgraded.

    1. cd into the src/ directory.

    2. Upgrade the database.

      flask db upgrade
  12. Start the applications that run the application.

    sudo systemctl start videodl_worker.service
    sudo systemctl start videodl.service