hoytech / strfry

a nostr relay
GNU General Public License v3.0
504 stars 98 forks source link

[Question] Recommended way to pass config values to plugin scripts? #129

Open chmac opened 11 hours ago

chmac commented 11 hours ago

Firstly, thanks for strfry, it looks to be an awesome relay. 🧡

We're pushing events as they come into our relay to a RabbitMQ so that we can do things like send push notifications and other background processing. We're running strfry inside a docker container. Our approach is to add our own custom plugin which simply returns accept and then forwards the event to our RabbitMQ server.

Our struggle is around setting the config values for our script. Our experiments suggest that the plugin script is invoked without its parent environment variables. As we're running in docker, that was our first thought, to use env vars to set the config values. Then we tried passing arguments like relay.writePolicy.plugin = "pusher --host=foo" but that throws an error that pusher --host=foo can't be found. Our next step is to grab the env of pid 1 and extract that. But this seems kinda ugly!

I'm curious if there is a recommended way to set config values for plugin scripts that are invoked by strfry?

hoytech commented 8 hours ago

Hi! What version of strfry are you using? I thought I fixed this in a relatively recent version. Environment variables should be propagated now and command-line flags should work (although with flags this disables the hot-reloading on binary change feature).

It's possible there is a bug of course! I will look into this soon. Another option of course is that you could read the options from a config file (although this might be more complicated with a docker setup).