|
1 | 1 | (caterva2.toml)= |
2 | 2 | # The `caterva2.toml` configuration file |
3 | 3 |
|
4 | | -We've seen that the `cat2-client` program accepts some command-line options to tune its operation (check the `--help` option). This is even more important for services as we shall see in following sections. Thus, Caterva2 programs support getting some settings from a TOML configuration file, by default `caterva2.toml` in the current directory (though you may override it with the `--conf` option). |
| 4 | +We've seen that the `cat2-client` program accepts some command-line options to tune its operation (check the `--help` option). This is even more important for services as we shall see in following sections. Thus, Caterva2 programs support getting some settings from a TOML configuration file. |
| 5 | + |
| 6 | +## Configuration File Search Path |
| 7 | + |
| 8 | +Caterva2 follows standard Unix/Linux conventions for locating configuration files. When looking for `caterva2.toml` (or `cat2-server.toml`), the search order is: |
| 9 | + |
| 10 | +1. **Command-line option**: `--conf <path>` (if explicitly specified) |
| 11 | +2. **Current directory**: `./caterva2.toml` |
| 12 | +3. **Home directory**: `~/.caterva2.toml` |
| 13 | +4. **System-wide** (Unix/Linux only): `/etc/caterva2.toml` |
| 14 | + |
| 15 | +The first existing file found in this order will be used. If no configuration file is found, the program will use default settings. |
| 16 | + |
| 17 | +This approach is similar to how tools like `git`, `vim`, and `ssh` locate their configuration files, making it familiar to Unix/Linux users. |
5 | 18 |
|
6 | 19 | The configuration file may hold settings for different programs, with a separate section for each program. Thus, a program may check the file for its own settings, but also for those of other programs which may be of use to itself. This allows compact configurations in a single file. For instance, below is a sample configuration file for the server program and some client app: |
7 | 20 |
|
8 | 21 | ```toml |
9 | | -# Example configuration for a standalone server |
10 | | -# |
11 | | -# It's possible to run only the server. Then the configuration has only a |
12 | | -# section for the server. And maybe another one for the client. |
13 | | - |
14 | | -# The server section must define: |
15 | | -# |
16 | | -# - statedir: the directory where the server's data will be stored (default: _caterva2/sub) |
17 | | -# - listen: where the server listens to (a unix socket or a host/port) (default: localhost:8002) |
18 | | -# - urlbase: the base url users will use to reach the server (default: http://localhost:8002) |
19 | | -# - quota: if defined, it will limit the disk usage (default: 0, no limit) |
20 | | -# - maxusers: if defined, it will limit the number of users (default: 0, no limit) |
21 | | -# - login: if true, users will need to authenticate (default: true) |
22 | | -# - register: if true, users will be able to register (default: false) |
23 | | -# |
24 | | -[server] |
25 | | -statedir = "_caterva2/state" |
26 | | -#listen = "_caterva2/sub/uvicorn.socket" |
27 | | -listen = "localhost:8000" |
28 | | -urlbase = "http://localhost:8000" |
29 | | -quota = "10G" |
30 | | -maxusers = 5 |
31 | | -register = true # allow users to register |
32 | | - |
33 | | -# The client section defines the credentials for the client to authenticate |
34 | | -# against the server. |
35 | | -[client] |
| 22 | +# Example configuration for caterva2 clients in general |
| 23 | +[default] |
| 24 | +url = "https://cat2.cloud/demo" |
36 | 25 | username = "" |
37 | 26 | password = "" |
| 27 | + |
| 28 | +[localuser] |
| 29 | +url = "http://localhost:8000" |
| 30 | +username = "user@example.com" |
| 31 | +password = "foobar11" |
38 | 32 | ``` |
39 | 33 |
|
40 | 34 | See [caterva2.sample.toml](https://github.com/ironArray/Caterva2/blob/main/caterva2.sample.toml) in Caterva2's source for all possible settings and their purpose. |
0 commit comments