When configuring iocaine via environment variables, sections and settings were separated by two underlines, but the `IOCAINE_` prefix only had one. This felt weird, so now iocaine supports an `IOCAINE__` prefix too, and keeps recognizing the old one too. Documentation and examples updated to use the new naming. No mention of the backwards compatibility - I'll just silently support that. Signed-off-by: Gergely Nagy <me@gergo.csillger.hu>
2.5 KiB
title | description |
---|---|
Configuration | Configuring Iocaine |
iocaine
can be configured via a TOML-format configuration file, or via the environment. Almost everything has sane defaults, but providing a wordlist, and at least one source for the markov generator is required.
The configuration file is split into three main sections: [server]
, [sources]
, and [generator]
.
[server]
The [server]
section is used to configure the address and port the server will listen on, via the bind
property. The default is shown below:
[server]
bind = "127.0.0.1:42069"
This parameter is available as IOCAINE__SERVER__BIND
when configuring via environment variables.
[sources]
The [sources]
section is the only section without defaults, specifying both options here is mandatory.
[sources]
words = "/usr/share/dict/wamerican.txt"
markov = ["/var/lib/iocaine/markov/bee-movie.txt", "/var/lib/iocaine/markov/moby-dick.txt"]
The first option, words
, refers to a word list file, with one word per line. When generating links, the path of the link will be a word chosen from this word list.
The second option, markov
, is a list of files used to train the markov chain generator. These will be used to generate the main content.
These parameters are available as IOCAINE__SOURCES__WORDS
and IOCAINE__SOURCES__MARKOV
, respectively, when configuring via environment variables. Do note that if configuring iocaine
this way, the IOCAINE__SOURCES__MARKOV
environment variable must be a TOML list: IOCAINE__SOURCES__MARKOV='["/var/lib/iocaine/markov/bee-movie.txt"]'
.
[generator]
The [generator]
section is used to describe how garbage is generated, how many paragraphs are produced per page, how many words they may have, how many links to place, and whether to add a "Back" link at the top. It looks like this, with defaults shown:
[generator.markov.paragraphs]
min = 1
max = 1
[generator.markov.words]
min = 10
max = 420
[generator.links]
min = 2
max = 5
backlink = true
[generator]
initial_seed = ""
When configuring through environment variables, these settings are available via IOCAINE__GENERATOR__MARKOV__PARAGRAPHS__MIN
, IOCAINE__GENERATOR__MARKOV__PARAGRAPHS_MAX
, IOCAINE__GENERATOR__MARKOV__WORDS__MIN
, IOCAINE__GENERATOR__MARKOV__WORDS__MAX
, IOCAINE__GENERATOR__LINKS__MIN
, IOCAINE__GENERATOR__LINKS__MAX
, and IOCAINE__GENERATOR__LINKS__BACKLINK
, IOCAINE__GENERATOR__INITIAL_SEED
respectively.