Flask app to run mokuro in a dedicated server, including a API
- Install Python (>= 3.10)
- Install Poetry (>= 1.6.1)
- Clone this repository
- Enter the repository folder (
cd mokuro-online
) - Install dependencies with poetry (
poetry install
) - Generate a random SECRET_KEY and add it to
config.py
- Edit Anything more you want in
config.py
You can see the commands here:
# Step 3 and 4, if you have GIT installed
git clone https://github.com/imsamuka/mokuro-online.git
cd mokuro-online
# Step 5 and 6
poetry install
sed -i "s/SECRET_KEY = .*/SECRET_KEY = '$(python3 -c 'import secrets; print(secrets.token_hex())')'/" config.py
# Step 7: Edit the file `config.py`
It's very simple, since it's local by default.
poetry run gunicorn
You can run it whoever you want. The thing you have to care the most is to use multi-threading instead of multi-processing, because the app depends on it.
This is an example /etc/systemd/system/mokuro-online.service
file for running this when the server starts. It will create a unix socket on /home/ubuntu/mokuro-online/mokuro-online.sock
, and you can for example, use nginx to proxy everything to it with SSL.
[Unit]
Description=Gunicorn instance to serve mokuro-online
After=network.target
[Service]
User=ubuntu
Group=www-data
WorkingDirectory=/home/ubuntu/mokuro-online
ExecStart=/usr/bin/poetry run gunicorn --bind unix:app.sock -m 007 "app:create_app('production')"
[Install]
WantedBy=multi-user.target
server {
listen 80;
server_name your_domain www.your_domain;
location / {
include proxy_params;
proxy_pass http://unix:/home/ubuntu/mokuro-online/app.sock;
client_max_body_size 150M;
}
}