-
-
Notifications
You must be signed in to change notification settings - Fork 0
Allowing user-defined settings for go-sbot #16
Description
This might not be the best place for this topic but I think it's OK for now, since it might alter the build process for peach-go-sbot
.
While playing with go-sbot and looking at all the ways to modify its behaviour using flags, I found myself wondering how we might allow for peach caretakers to alter the behaviour of their go-sbot instances in PeachCloud.
As a simple example: the hops count currently defaults to 1 but can be set to 2 by passing the -hops 2
flag (go-sbot -hops 2
). Other examples include setting a non-standard network key (to create a cypherverse separate from the Scuttleverse), setting a custom mountpoint for the .ssb-go
directory, or enabling local network discovery by listening for UDP packets and connecting to the source server.
Defaults for all of the above examples, and more, are defined in ssb/main.go.
Let's imagine an 'SSB Server Configuration' page on the peach-web
interface which allows these various settings to be modified; how might we go about storing the settings and applying them to our go-sbot
instance?
Currently we use a systemd
service file which simply calls /usr/bin/go-sbot
. One possible solution would be to create an argument config file defining all of the go-sbot
flags and import it into the service file using the EnvironmentFile
parameter (as described in this superuser post).
So we would have a config file (for example, /etc/.go-sbot.conf
) with a list of flags:
DISCOV=-localdiscov true
EBT=-enable-ebt true
And we'd pass them to go-sbot
as arguments in the service file:
EnvironmentFile=/etc/.go-sbot.conf
ExecStart = /usr/bin/go-sbot $DISCOV $EBT
With this approach, I imagine any changes to the settings on the 'SSB Server Configuration' page would result in the following events: 1) stop the peach-go-sbot
service, 2) write the changes to the /etc/.go-sbot.conf
file, 3) start the peach-go-sbot
service. We could keep a backup of the default settings at /etc/.go-sbot.conf.bak
, which would allow us to have a Reset to default
option in the web interface (overwrite /etc/.go-sbot.conf
with /etc/.go-sbot.conf.bak
).
@mhfowler I'm interested to hear your thoughts on this. Maybe you've tackled a similar problem in the past? I'm going to do some more research to see what other approaches there are. I imagine it also wouldn't be difficult to fork go-sbot
and customise main.go
to read the flags directly from a config file (instead of parsing them from arguments). Then we could continue to run /usr/bin/go-sbot
in the service file and alter the conf file as needed.