gotify / server

A simple server for sending and receiving messages in real-time per WebSocket. (Includes a sleek web-ui)
https://gotify.net
Other
10.43k stars 593 forks source link

Running multiple plugin instances #618

Closed mStirner closed 5 months ago

mStirner commented 5 months ago

Have you read the documentation?

You are setting up gotify in

Describe your problem I have the need to run a plugin multiple times. Simply copying the file multiple times to ´/app/data/plugins/´ does not work and let the container crash.

I want to subscribe to multiple mqtt topics (https://github.com/tystuyfzand/gotify-mqtt), where each topic should be his own gotify application.

Any errors, logs, or other information that might help us identify your problem

Ex: docker-compose.yml, nginx.conf, android logcat, browser requests, etc.

docker logs output

```
Starting Gotify version 2.4.0@2023-09-17-08:24:00
Loading plugin data/plugins/mqtt-linux-amd64-2.so
Loading plugin data/plugins/mqtt-linux-amd64.so
panic: error while loading plugin mqtt-linux-amd64.so: plugin.Open("data/plugins/mqtt-linux-amd64"): plugin already loaded

goroutine 1 [running]:
github.com/gotify/server/v2/router.Create(0xc00053e9e0, 0xc00049f9b0, 0xc00010ca80)
    /proj/router/router.go:59 +0x2cbb
main.main()
    /proj/app.go:51 +0x2ec
Starting Gotify version 2.4.0@2023-09-17-08:24:00
Loading plugin data/plugins/mqtt-linux-amd64-2.so
Loading plugin data/plugins/mqtt-linux-amd64.so
panic: error while loading plugin mqtt-linux-amd64.so: plugin.Open("data/plugins/mqtt-linux-amd64"): plugin already loaded

goroutine 1 [running]:
github.com/gotify/server/v2/router.Create(0xc0000a09c8, 0xc0006297d0, 0xc000002a80)
    /proj/router/router.go:59 +0x2cbb
main.main()
    /proj/app.go:51 +0x2ec
``

jmattheis commented 5 months ago

Golang currently doesn't allow loading the same plugin twice with different names https://github.com/golang/go/issues/47298

Your required functionality could be included as a feature request in the gotify-mqtt project or you could build the plugin with a different package path yourself.

$ git clone https://github.com/tystuyfzand/gotify-mqtt.git
$ cd gotify-mqtt
$ sed -i 's|gotify-mqtt|gotify-mqtt-copy|' go.mod plugin.go
$ make GOTIFY_VERSION="v2.4.0" FILE_SUFFIX="for-gotify-v2.4.0" build-linux-amd64

and then move the build/mqtt-linux-amd64for-gotify-v2.4.0.so file into your plugin directory.

mStirner commented 5 months ago

Have opend a issue on the plugin, but i think this also get ignored like my other question. I think the only solution i have is the one you provided.

But i ran in to the following error while building the plugin:

make GOTIFY_VERSION="v2.4.0" FILE_SUFFIX="for-gotify-v2.4.0" build-linux-amd64
mkdir -p ./build || true
rm ./build/gotify-server-go-version || true
wget -O ./build/gotify-server-go-version https://raw.githubusercontent.com/gotify/server/v2.4.0/GO_VERSION
--2024-01-09 11:34:34--  https://raw.githubusercontent.com/gotify/server/v2.4.0/GO_VERSION
Auflösen des Hostnamens raw.githubusercontent.com (raw.githubusercontent.com) … 185.199.108.133, 185.199.111.133, 185.199.110.133, ...
Verbindungsaufbau zu raw.githubusercontent.com (raw.githubusercontent.com)|185.199.108.133|:443 … verbunden.
HTTP-Anforderung gesendet, auf Antwort wird gewartet … 200 OK
Länge: 7 [text/plain]
Wird in »./build/gotify-server-go-version« gespeichert.

./build/gotify-server-go-version                   100%[================================================================================================================>]       7  --.-KB/s    in 0s      

2024-01-09 11:34:34 (147 KB/s) - »./build/gotify-server-go-version« gespeichert [7/7]

go install github.com/gotify/plugin-api/cmd/gomod-cap@latest
wget -O ./build/gotify-server.mod https://raw.githubusercontent.com/gotify/server/v2.4.0/go.mod
--2024-01-09 11:34:34--  https://raw.githubusercontent.com/gotify/server/v2.4.0/go.mod
Auflösen des Hostnamens raw.githubusercontent.com (raw.githubusercontent.com) … 185.199.108.133, 185.199.111.133, 185.199.110.133, ...
Verbindungsaufbau zu raw.githubusercontent.com (raw.githubusercontent.com)|185.199.108.133|:443 … verbunden.
HTTP-Anforderung gesendet, auf Antwort wird gewartet … 200 OK
Länge: 2165 (2,1K) [text/plain]
Wird in »./build/gotify-server.mod« gespeichert.

./build/gotify-server.mod                          100%[================================================================================================================>]   2,11K  --.-KB/s    in 0s      

2024-01-09 11:34:34 (16,8 MB/s) - »./build/gotify-server.mod« gespeichert [2165/2165]

gomod-cap -from ./build/gotify-server.mod -to go.mod
make: gomod-cap: Command not found
Makefile:18: recipe for target 'update-go-mod' failed
make: *** [update-go-mod] Error 127
jmattheis commented 5 months ago

Try running make download-tools before the other make command.

mStirner commented 5 months ago

Unfortunately, same error:

marc@stirner:~/projects/playground/gotify-mqtt$ make download-tools
go install github.com/gotify/plugin-api/cmd/gomod-cap@latest
marc@stirner:~/projects/playground/gotify-mqtt$ make GOTIFY_VERSION="v2.4.0" FILE_SUFFIX="for-gotify-v2.4.0" build-linux-amd64
mkdir -p ./build || true
rm ./build/gotify-server-go-version || true
wget -O ./build/gotify-server-go-version https://raw.githubusercontent.com/gotify/server/v2.4.0/GO_VERSION
--2024-01-09 12:50:20--  https://raw.githubusercontent.com/gotify/server/v2.4.0/GO_VERSION
Auflösen des Hostnamens raw.githubusercontent.com (raw.githubusercontent.com) … 185.199.110.133, 185.199.111.133, 185.199.108.133, ...
Verbindungsaufbau zu raw.githubusercontent.com (raw.githubusercontent.com)|185.199.110.133|:443 … verbunden.
HTTP-Anforderung gesendet, auf Antwort wird gewartet … 200 OK
Länge: 7 [text/plain]
Wird in »./build/gotify-server-go-version« gespeichert.

./build/gotify-server-go-version                   100%[================================================================================================================>]       7  --.-KB/s    in 0s      

2024-01-09 12:50:20 (273 KB/s) - »./build/gotify-server-go-version« gespeichert [7/7]

go install github.com/gotify/plugin-api/cmd/gomod-cap@latest
wget -O ./build/gotify-server.mod https://raw.githubusercontent.com/gotify/server/v2.4.0/go.mod
--2024-01-09 12:50:20--  https://raw.githubusercontent.com/gotify/server/v2.4.0/go.mod
Auflösen des Hostnamens raw.githubusercontent.com (raw.githubusercontent.com) … 185.199.109.133, 185.199.108.133, 185.199.111.133, ...
Verbindungsaufbau zu raw.githubusercontent.com (raw.githubusercontent.com)|185.199.109.133|:443 … verbunden.
HTTP-Anforderung gesendet, auf Antwort wird gewartet … 200 OK
Länge: 2165 (2,1K) [text/plain]
Wird in »./build/gotify-server.mod« gespeichert.

./build/gotify-server.mod                          100%[================================================================================================================>]   2,11K  --.-KB/s    in 0s      

2024-01-09 12:50:20 (11,3 MB/s) - »./build/gotify-server.mod« gespeichert [2165/2165]

gomod-cap -from ./build/gotify-server.mod -to go.mod
make: gomod-cap: Command not found
Makefile:18: recipe for target 'update-go-mod' failed
make: *** [update-go-mod] Error 127
jmattheis commented 5 months ago

make download-tools installs a go binary in $HOME/go/bin, you need to have this directory on your $PATH.