Go to file
queue 044cb143bf sync_es: fix flush_interval behavior during slow times
instead of flushing every N seconds, it flushed N seconds after
the last change, which could drag out to N seconds * M batch size
if there are few updates. Practically this doesn't change anything
since stuff is always happening.

Also fix not writing a save point if nothing is happening. Also
practically does nothing, but for correctness.
2017-05-28 22:19:25 -06:00
.github Update issue_template.md 2017-05-17 13:02:09 +03:00
configs moved some files 2017-05-17 00:53:54 -07:00
migrations shameful late edit: change comment text collation to utf8mb4 2017-05-23 00:36:53 +02:00
nyaa Remove username validator from login form to allow logging in with email 2017-05-26 23:28:28 +03:00
torrent_cache Initial commit. 2017-05-12 20:51:49 +02:00
utils Remove v1 upload api and update notice 2017-05-22 22:57:37 +03:00
.gitignore Make sure torrent backup directory exists before writing torrent 2017-05-13 02:41:52 +03:00
.travis.yml Use pycodestyle 2017-05-17 12:25:55 +03:00
LICENSE Add license (GPLv3) 2017-05-13 01:03:42 +03:00
README.md readme: Clean up setup instructions 2017-05-23 11:55:22 +00:00
WSGI.py Add flask-Migrate + alembic for automated database migrations. 2017-05-21 17:47:16 +02:00
config.example.py utf8mb4 for database connection 2017-05-23 00:46:26 +02:00
config_es_sync.json sync_es: move io to separate threads, config json 2017-05-21 00:55:19 -06:00
create_es.sh hooked up ES... 90% done, need to figure out how to generate magnet URIs 2017-05-15 23:51:58 -07:00
db_create.py Add flask-Migrate + alembic for automated database migrations. 2017-05-21 17:47:16 +02:00
db_migrate.py Add flask-Migrate + alembic for automated database migrations. 2017-05-21 17:47:16 +02:00
es_mapping.yml Resolves #129 and refactored create magnet es naming 2017-05-24 23:19:08 -07:00
import_to_es.py Add flask-Migrate + alembic for automated database migrations. 2017-05-21 17:47:16 +02:00
lint.sh Initial commit. 2017-05-12 20:51:49 +02:00
requirements.txt Add flask-Migrate + alembic for automated database migrations. 2017-05-21 17:47:16 +02:00
run.py Add flask-Migrate + alembic for automated database migrations. 2017-05-21 17:47:16 +02:00
sync_es.py sync_es: fix flush_interval behavior during slow times 2017-05-28 22:19:25 -06:00
trackers.txt Update trackers.txt 2017-05-22 23:36:34 +02:00
uwsgi.ini Initial commit. 2017-05-12 20:51:49 +02:00

README.md

NyaaV2

Setup

Setting up MySQL/MariaDB database for advanced functionality

  • Enable USE_MYSQL flag in config.py
  • Install latest mariadb by following instructions here https://downloads.mariadb.org/mariadb/repositories/
    • Tested versions: mysql Ver 15.1 Distrib 10.0.30-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
  • Run the following commands logged in as your root db user:
    • CREATE USER 'test'@'localhost' IDENTIFIED BY 'test123';
    • GRANT ALL PRIVILEGES ON * . * TO 'test'@'localhost';
    • FLUSH PRIVILEGES;
    • CREATE DATABASE nyaav2 DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
  • To setup and import nyaa_maria_vx.sql:
    • mysql -u <user> -p nyaav2
    • DROP DATABASE nyaav2;
    • CREATE DATABASE nyaav2 DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
    • SOURCE ~/path/to/database/nyaa_maria_vx.sql

Finishing up

  • Run python db_create.py to create the database
  • Load the .sql file
    • mysql -u user -p nyaav2
    • SOURCE cocks.sql
    • Remember to change the default user password to an empty string to disable logging in
  • Start the dev server with python run.py
  • When you are finished developing, deactivate your virtualenv with source deactivate

Enabling ElasticSearch

Basics

Enable MySQL Binlogging

  • Add the [mariadb] bin-log section to my.cnf and reload mysql server
  • Connect to mysql
  • SHOW VARIABLES LIKE 'binlog_format';
    • Make sure it shows ROW
  • Connect to root user
  • GRANT REPLICATION SLAVE ON *.* TO 'test'@'localhost'; where test is the user you will be running sync_es.py with

Setting up ES

  • Run ./create_es.sh and this creates two indicies: nyaa and sukebei
  • The output should show acknowledged: true twice
  • The safest bet is to disable the webapp here to ensure there's no database writes
  • Run python import_to_es.py with SITE_FLAVOR set to nyaa
  • Run python import_to_es.py with SITE_FLAVOR set to sukebei
  • These will take some time to run as it's indexing

Setting up sync_es.py

  • Sync_es.py keeps the ElasticSearch index updated by reading the BinLog
  • Configure the MySQL options with the user where you granted the REPLICATION permissions
  • Connect to MySQL, run SHOW MASTER STATUS;.
  • Copy the output to /var/lib/sync_es_position.json with the contents {"log_file": "FILE", "log_pos": POSITION} and replace FILENAME with File (something like master1-bin.000002) in the SQL output and POSITION (something like 892528513) with Position
  • Set up sync_es.py as a service and run it, preferably as the system/root
  • Make sure sync_es.py runs within venv with the right dependencies

Enable the USE_ELASTIC_SEARCH flag in config.py, restart the application, and you're good to go.

Database migrations

  • Uses flask-Migrate
  • Run ./db_migrate.py db migrate to generate the migration script after database model changes.
  • Take a look at the result in migrations/versions/... to make sure nothing went wrong.
  • Run ./db_migrate.py db upgrade to upgrade your database.

Code Quality:

  • Remember to follow PEP8 style guidelines and run ./lint.sh before committing.