2020-10-15 10:40:53 +00:00
# Flaschengeist
2021-12-14 14:36:08 +00:00
![status-badge ](https://ci.os-sc.org/api/badges/Flaschengeist/flaschengeist/status.svg )
2021-05-20 15:37:17 +00:00
This is the backend of the Flaschengeist.
2020-10-15 10:40:53 +00:00
## Installation
### Requirements
2021-05-26 23:52:45 +00:00
- `mysql` or `mariadb`
- maybe `libmariadb` development files[1]
2021-12-26 14:44:04 +00:00
- python 3.9+
2021-12-26 14:42:31 +00:00
- pip 21.0+
2021-05-26 23:52:45 +00:00
2021-12-26 14:42:31 +00:00
*[1] By default Flaschengeist uses mysql as database backend, if you are on Windows Flaschengeist uses `PyMySQL` , but on
2021-05-26 23:52:45 +00:00
Linux / Mac the faster `mysqlclient` is used, if it is not already installed installing from pypi requires the
2021-12-26 14:42:31 +00:00
development files for `libmariadb` to be present on your system.*
2021-05-26 23:52:45 +00:00
2020-10-15 10:40:53 +00:00
### Install python files
2021-12-26 14:42:31 +00:00
It is recommended to upgrade pip to the latest version before installing:
python -m pip install --upgrade pip
Default installation with *mariadb* /*mysql* support:
pip3 install --user ".[mysql]"
2020-10-15 10:40:53 +00:00
or with ldap support
pip3 install --user ".[ldap]"
2021-12-26 14:42:31 +00:00
2021-01-24 15:19:46 +00:00
or if you want to also run the tests:
2020-10-28 13:21:54 +00:00
2021-12-26 14:42:31 +00:00
pip3 install --user ".[ldap,tests]"
2020-10-28 13:21:54 +00:00
2021-12-19 23:53:49 +00:00
You will also need a MySQL driver, by default one of this is installed:
- `mysqlclient` (non Windows)
- `PyMySQL` (on Windows)
2021-01-25 12:09:20 +00:00
2021-12-19 23:53:49 +00:00
#### Hint on MySQL driver on Windows:
If you want to use `mysqlclient` instead of `PyMySQL` (performance?) you have to follow [this guide ](https://www.radishlogic.com/coding/python-3/installing-mysqldb-for-python-3-in-windows/ )
2021-03-18 13:05:28 +00:00
2021-12-19 23:53:49 +00:00
### Install database
The user needs to have full permissions to the database.
If not you need to create user and database manually do (or similar on Windows):
(
echo "CREATE DATABASE flaschengeist;"
echo "CREATE USER 'flaschengeist'@'localhost' IDENTIFIED BY 'flaschengeist';"
echo "GRANT ALL PRIVILEGES ON flaschengeist.* TO 'flaschengeist'@'localhost';"
echo "FLUSH PRIVILEGES;"
) | sudo mysql
Then you can install the database tables, this will update all tables from core + all enabled plugins.
*Hint:* The same command can be later used to upgrade the database after plugins or core are updated.
$ flaschengeist db upgrade heads
## Plugins
To only upgrade one plugin (for example the `events` plugin):
2020-10-27 12:43:01 +00:00
2021-12-19 23:53:49 +00:00
$ flaschengeist db upgrade events@head
2020-10-15 10:40:53 +00:00
2021-12-19 23:53:49 +00:00
## Configuration
2021-01-25 12:09:20 +00:00
Configuration is done within the a `flaschengeist.toml` file, you can copy the one located inside the module path
(where flaschegeist is installed) or create an empty one and place it inside either:
1. `~/.config/`
2. A custom path and set environment variable `FLASCHENGEIST_CONF`
2021-05-20 15:37:17 +00:00
Uncomment and change at least all the database parameters!
2020-10-15 10:40:53 +00:00
2021-12-06 22:48:05 +00:00
#### CRON
Some functionality used by some plugins rely on regular updates,
but as flaschengeists works as an WSGI app it can not controll when it gets called.
So you have to configure one of the following options to call flaschengeists CRON tasks:
1. Passive Web-CRON: Every time an users calls flaschengeist a task is scheduled (**NOT RECOMMENDED**)
- Pros: No external configuration needed
- Cons: Slower user experience, no guaranteed execution time of tasks
2. Active Web-CRON: You configure a webworker to call `<flaschengeist>/cron`
- Pros: Guaranteed execution interval, no impact on user experience (at least if you do not limit wsgi worker threads)
- Cons: Uses one of the webserver threads while executing
2020-10-15 10:40:53 +00:00
### Run
2022-02-13 22:01:49 +00:00
Flaschengeist provides a CLI, based on the flask CLI, respectivly called `flaschengeist` .
⚠️ When using the CLI for running Flaschengeist, please note that logging will happen as configured,
with the difference of the main logger will be forced to output to `stderr` and the logging level
of the CLI will override the logging level you have configured for the main logger.
2021-12-18 01:00:46 +00:00
$ flaschengeist run
2020-10-15 10:40:53 +00:00
or with debug messages:
2021-12-18 01:00:46 +00:00
$ flaschengeist run --debug
2021-01-24 15:19:46 +00:00
2021-05-20 15:37:17 +00:00
This will run the backend on http://localhost:5000
2021-01-24 15:19:46 +00:00
## Tests
$ pip install '.[test]'
$ pytest
Run with coverage report:
$ coverage run -m pytest
$ coverage report
Or with html output (open `htmlcov/index.html` in a browser):
$ coverage html
2020-10-15 12:44:58 +00:00
2020-10-15 20:16:26 +00:00
## Development
2021-12-14 14:36:08 +00:00
Please refer to our [development wiki ](https://flaschengeist.dev/Flaschengeist/flaschengeist/wiki/Development ).