Make db and log config options more future-proof

Rename the "sql" directive to "db". Rename the "log" directive to
"log fs".

In the future, we'll maybe support more databases and more message
stores. Make it so it's easy to integrate these new festures to the
config file format.

git-svn-id: file:///srv/svn/repo/suika/trunk@507 f0ae65fe-ee39-954e-97ec-027ff2717ef4
This commit is contained in:
contact 2021-04-21 16:15:04 +00:00
parent 3922196855
commit 7bfba6f771
3 changed files with 11 additions and 9 deletions

View File

@ -1,2 +1,2 @@
sql sqlite3 /var/lib/soju/main.db db sqlite3 /var/lib/soju/main.db
log /var/lib/soju/logs/ log fs /var/lib/soju/logs/

View File

@ -86,14 +86,18 @@ func parse(cfg scfg.Block) (*Server, error) {
return nil, err return nil, err
} }
srv.TLS = tls srv.TLS = tls
case "sql": case "db":
if err := d.ParseParams(&srv.SQLDriver, &srv.SQLSource); err != nil { if err := d.ParseParams(&srv.SQLDriver, &srv.SQLSource); err != nil {
return nil, err return nil, err
} }
case "log": case "log":
if err := d.ParseParams(&srv.LogPath); err != nil { var driver string
if err := d.ParseParams(&driver, &srv.LogPath); err != nil {
return nil, err return nil, err
} }
if driver != "fs" {
return nil, fmt.Errorf("directive %q: unknown driver %q", d.Name, driver)
}
case "http-origin": case "http-origin":
srv.HTTPOrigins = d.Params srv.HTTPOrigins = d.Params
case "accept-proxy-ip": case "accept-proxy-ip":

View File

@ -101,12 +101,10 @@ The following directives are supported:
*tls* <cert> <key> *tls* <cert> <key>
Enable TLS support. The certificate and the key files must be PEM-encoded. Enable TLS support. The certificate and the key files must be PEM-encoded.
*sql* <driver> <source> *db* sqlite3 <path>
Set the SQL driver settings. The only supported driver is "sqlite3". The Set the SQLite database path (default: "soju.db" in the current directory).
source is the path to the SQLite database file. By default, the path to the
database file is "soju.db".
*log* <path> *log* fs <path>
Path to the bouncer logs root directory, or empty to disable logging. By Path to the bouncer logs root directory, or empty to disable logging. By
default, logging is disabled. default, logging is disabled.