2021-12-24 13:53:55 -08:00
|
|
|
NiceDB / NeoDB - Getting Start
|
|
|
|
==============================
|
|
|
|
This is a very basic guide with limited detail, contributions welcomed
|
|
|
|
|
|
|
|
Install
|
|
|
|
-------
|
2023-01-05 03:06:13 -05:00
|
|
|
Install PostgreSQL, Redis and Python (3.10 or above) if not yet
|
2021-12-24 13:53:55 -08:00
|
|
|
|
|
|
|
Setup database
|
|
|
|
```
|
|
|
|
CREATE DATABASE neodb ENCODING 'UTF8' LC_COLLATE='en_US.UTF-8' LC_CTYPE='en_US.UTF-8' TEMPLATE template0;
|
|
|
|
\c neodb;
|
|
|
|
CREATE ROLE neodb with LOGIN ENCRYPTED PASSWORD 'abadface';
|
|
|
|
GRANT ALL ON DATABASE neodb TO neodb;
|
|
|
|
```
|
|
|
|
|
|
|
|
Create and edit your own configuration file (optional but very much recommended)
|
|
|
|
```
|
|
|
|
mkdir mysite && cp boofilsic/settings.py mysite/
|
|
|
|
export DJANGO_SETTINGS_MODULE=mysite.settings
|
|
|
|
```
|
2023-01-11 22:52:07 -05:00
|
|
|
Alternatively you can have a configuration file import `boofilsic/settings.py` then override it:
|
|
|
|
```
|
|
|
|
from boofilsic.settings import *
|
|
|
|
|
|
|
|
SECRET_KEY = "my_key"
|
|
|
|
```
|
2022-12-13 16:33:58 -05:00
|
|
|
More details on `settings.py` in [configuration.md](configuration.md)
|
2021-12-24 13:53:55 -08:00
|
|
|
|
2023-01-11 22:52:07 -05:00
|
|
|
Create and use `venv` as you normally would, then install packages
|
2021-12-24 13:53:55 -08:00
|
|
|
```
|
|
|
|
python3 -m pip install -r requirements.txt
|
2023-01-11 22:52:07 -05:00
|
|
|
|
2021-12-24 13:53:55 -08:00
|
|
|
```
|
|
|
|
|
|
|
|
Quick check
|
|
|
|
```
|
|
|
|
python3 manage.py check
|
|
|
|
```
|
|
|
|
|
|
|
|
Initialize database
|
|
|
|
```
|
|
|
|
python3 manage.py migrate
|
|
|
|
```
|
|
|
|
|
2023-06-01 14:49:19 -04:00
|
|
|
Build static assets (production only)
|
2021-12-24 13:53:55 -08:00
|
|
|
```
|
2023-05-20 11:01:18 -04:00
|
|
|
python3 manage.py compilescss
|
2021-12-24 13:53:55 -08:00
|
|
|
python3 manage.py collectstatic
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
Start services
|
|
|
|
--------------
|
|
|
|
Make sure PostgreSQL and Redis are running
|
|
|
|
|
|
|
|
Start job queue server
|
|
|
|
```
|
|
|
|
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES # required and only for macOS, otherwise it may crash
|
2023-01-11 22:52:07 -05:00
|
|
|
python3 manage.py rqworker --with-scheduler import export mastodon fetch crawl
|
2021-12-24 13:53:55 -08:00
|
|
|
```
|
|
|
|
|
|
|
|
Run web server in dev mode
|
|
|
|
```
|
2023-01-11 22:52:07 -05:00
|
|
|
python3 manage.py runserver
|
2021-12-24 13:53:55 -08:00
|
|
|
```
|
|
|
|
|
|
|
|
It should be ready to serve from here, to run web server for production, consider `gunicorn -w 8 boofilsic.wsgi` in systemd or sth similar
|
|
|
|
|
|
|
|
|
|
|
|
Migrate from an earlier version
|
|
|
|
-------------------------------
|
|
|
|
Update database
|
|
|
|
```
|
|
|
|
python3 manage.py migrate
|
|
|
|
```
|
|
|
|
|
|
|
|
Rebuild static assets
|
|
|
|
```
|
|
|
|
python3 manage.py sass common/static/sass/boofilsic.sass common/static/css/boofilsic.min.css -t compressed
|
|
|
|
python3 manage.py sass common/static/sass/boofilsic.sass common/static/css/boofilsic.css
|
|
|
|
python3 manage.py collectstatic
|
|
|
|
```
|
|
|
|
|
2022-07-31 03:07:11 -04:00
|
|
|
Add Cron Jobs
|
|
|
|
-------------
|
|
|
|
add `python manage.py refresh_mastodon` to crontab to run hourly, it will refresh cached users' follow/mute/block from mastodon
|
|
|
|
|
2022-07-31 02:37:59 -04:00
|
|
|
Index and Search
|
|
|
|
----------------
|
|
|
|
Install TypeSense or Meilisearch, change `SEARCH_BACKEND` and coniguration for search server in `settings.py`
|
|
|
|
|
|
|
|
Build initial index, it may take a few minutes or hours
|
|
|
|
```
|
2023-01-11 22:52:07 -05:00
|
|
|
python3 manage.py index --init
|
|
|
|
python3 manage.py index --reindex
|
2022-07-31 02:37:59 -04:00
|
|
|
```
|
2021-12-24 13:53:55 -08:00
|
|
|
|
|
|
|
Other maintenance tasks
|
|
|
|
-----------------------
|
2023-01-11 22:52:07 -05:00
|
|
|
Requeue failed import jobs
|
2021-12-24 13:53:55 -08:00
|
|
|
```
|
2023-01-11 22:52:07 -05:00
|
|
|
rq requeue --all --queue import
|
2021-12-24 13:53:55 -08:00
|
|
|
```
|
2022-09-13 15:47:35 -04:00
|
|
|
|
|
|
|
Run in Docker
|
|
|
|
```
|
|
|
|
docker-compose build
|
|
|
|
docker-compose up
|
|
|
|
```
|
2022-11-10 14:17:48 -05:00
|
|
|
|
|
|
|
Run Tests
|
|
|
|
```
|
|
|
|
coverage run --source='.' manage.py test
|
|
|
|
coverage report
|
|
|
|
```
|