gotify / server

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

Plugins dependency issues when starting server #319

Closed siredwin closed 4 years ago

siredwin commented 4 years ago

I can manage to build both the server and plugins separately, but the server doesn't start because of versioning issues. I have tried following the docker example but I don't think it works for me. What exactly is the below command supposed to do:

$ docker run --rm -v "$PWD/.:/proj" -w /proj gotify/build:1.12.0-linux-amd64 \
   go build -a -installsuffix cgo -ldflags "-w -s" -buildmode=plugin -o yourplugin-amd64.so /proj

I see a docker run and go build but I don't see the connection.

jmattheis commented 4 years ago

The command builds the plugin inside a docker container. This is done because of compatibility.

How do you build the server? Do you use the same gotify/build image? What kind of output do you see.

siredwin commented 4 years ago

I am still trying to build v2.0.0 (using docker).

This is all it does when I follow that example.

docker run --rm -v "$PWD/.:/proj" -w /proj gotify/build:1.12.0-linux-amd64 \
>    go build -a -installsuffix cgo -ldflags "-w -s" -buildmode=plugin -o yourplugin-amd64.so /proj
Unable to find image 'gotify/build:1.12.0-linux-amd64' locally
1.12.0-linux-amd64: Pulling from gotify/build
741437d97401: Pull complete 
34d8874714d7: Pull complete 
0a108aa26679: Pull complete 
7f0334c36886: Pull complete 
d35724ed4672: Pull complete 
d0ea18b1198f: Pull complete 
647e63f91386: Pull complete 
Digest: sha256:adf660457c257b2651f5d0726f73e7ee483e6acffd4ee84bb24fe361aa6aa40f
Status: Downloaded newer image for gotify/build:1.12.0-linux-amd64
go: finding github.com/gin-gonic/gin v1.6.3
go: finding github.com/gobuffalo/logger v1.0.3
go: finding github.com/pkg/errors v0.8.1
go: finding github.com/gin-contrib/cors v1.3.1
go: finding github.com/gotify/configor v1.0.2-0.20190112111140-7d9c7c7e6233
go: finding github.com/gotify/plugin-api v1.0.0
go: finding github.com/go-yaml/yaml v2.1.0+incompatible
go: finding github.com/Southclaws/configor v1.0.0
go: finding github.com/robfig/cron v0.0.0-20180505203441-b41be1df6967
go: finding github.com/gorilla/websocket v1.4.0
go: finding github.com/pkg/errors v0.8.0
go: finding github.com/go-playground/validator/v10 v10.2.0
go: finding github.com/fortytw2/leaktest v1.3.0
go: finding github.com/stretchr/testify v1.5.1
go: finding github.com/json-iterator/go v1.1.5
go: finding github.com/gotify/location v0.0.0-20170722210143-03bc4ad20437
go: finding github.com/gobuffalo/packr/v2 v2.7.1
go: finding github.com/stretchr/testify v1.3.0
go: finding golang.org/x/net v0.0.0-20190110200230-915654e7eabc
go: finding github.com/gobuffalo/packd v1.0.0
go: finding gopkg.in/yaml.v2 v2.2.2
go: finding gopkg.in/yaml.v2 v2.2.1
go: finding github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
go: finding github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7
go: finding github.com/gin-contrib/gzip v0.0.1
go: finding github.com/mattn/go-isatty v0.0.4
go: finding golang.org/x/tools v0.0.0-20191004055002-72853e10c5a3
go: finding github.com/modern-go/reflect2 v1.0.1
go: finding github.com/gobuffalo/envy v1.9.0
go: finding golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3
go: finding github.com/gin-gonic/gin v1.5.0
go: finding github.com/sirupsen/logrus v1.4.2
go: finding github.com/gobuffalo/logger v1.0.1
go: finding golang.org/x/net v0.0.0-20181220203305-927f97764cc3
go: finding github.com/gin-gonic/gin v1.3.0
go: finding github.com/golang/protobuf v1.4.1
go: finding github.com/spf13/cobra v0.0.5
go: finding github.com/go-playground/universal-translator v0.16.0
go: finding golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4
go: finding golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79
go: finding github.com/rogpeppe/go-internal v1.4.0
go: finding github.com/BurntSushi/toml v0.3.0
go: finding github.com/inconshreveable/mousetrap v1.0.0
go: finding golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4
go: finding github.com/go-playground/locales v0.13.0
go: finding google.golang.org/protobuf v1.22.0
go: finding gopkg.in/go-playground/validator.v9 v9.29.1
go: finding github.com/spf13/viper v1.3.2
go: finding github.com/gobuffalo/envy v1.7.0
go: finding golang.org/x/sys v0.0.0-20190109145017-48ac38b7c8cb
go: finding gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127
go: finding github.com/jinzhu/gorm v1.9.11
go: finding github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8
go: finding github.com/lib/pq v1.1.1
go: finding github.com/BurntSushi/toml v0.3.1
go: finding github.com/mitchellh/mapstructure v1.1.2
go: finding golang.org/x/crypto v0.0.0-20191122220453-ac88ee75c92c
go: finding github.com/pmezard/go-difflib v1.0.0
go: finding github.com/fsnotify/fsnotify v1.4.7
go: finding github.com/golang/protobuf v1.2.0
go: finding github.com/gin-contrib/sse v0.1.0
go: finding github.com/mattn/go-isatty v0.0.12
go: finding golang.org/x/sys v0.0.0-20190422165155-953cdadca894
go: finding github.com/ugorji/go/codec v0.0.0-20181022190402-e5e69e061d4f
go: finding github.com/golang/protobuf v1.3.2
go: finding github.com/konsorten/go-windows-terminal-sequences v1.0.1
go: finding github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5
go: finding golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3
go: finding github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77
go: finding github.com/spf13/jwalterweatherman v1.0.0
go: finding github.com/gobuffalo/packd v0.3.0
go: finding github.com/coreos/go-semver v0.2.0
go: finding github.com/rogpeppe/go-internal v1.5.2
go: finding github.com/stretchr/testify v1.2.2
go: finding github.com/rogpeppe/go-internal v1.1.0
go: finding github.com/mitchellh/go-homedir v1.1.0
go: finding github.com/golang/protobuf v1.4.0
go: finding github.com/davecgh/go-spew v1.1.0
go: finding github.com/joho/godotenv v1.3.0
go: finding golang.org/x/sys v0.0.0-20190412213103-97732733099d
go: finding github.com/stretchr/objx v0.1.0
go: finding github.com/h2non/filetype v1.0.10
go: finding github.com/go-sql-driver/mysql v1.4.1
go: finding github.com/jinzhu/now v1.0.1
go: finding github.com/go-playground/universal-translator v0.17.0
go: finding github.com/mattn/go-sqlite3 v2.0.3+incompatible
go: finding github.com/cpuguy83/go-md2man v1.0.10
go: finding github.com/spf13/cast v1.3.0
go: finding github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6
go: finding github.com/spf13/afero v1.1.2
go: finding github.com/russross/blackfriday v1.5.2
go: finding golang.org/x/text v0.3.2
go: finding github.com/pelletier/go-toml v1.2.0
go: finding github.com/coreos/go-etcd v2.0.0+incompatible
go: finding github.com/rogpeppe/go-internal v1.3.0
go: finding github.com/magiconair/properties v1.8.0
go: finding gopkg.in/errgo.v2 v2.1.0
go: finding github.com/davecgh/go-spew v1.1.1
go: finding github.com/kr/pretty v0.1.0
go: finding github.com/konsorten/go-windows-terminal-sequences v1.0.2
go: finding golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb
go: finding google.golang.org/protobuf v1.21.0
go: finding golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
go: finding github.com/ugorji/go/codec v0.0.0-20181209151446-772ced7fd4c2
go: finding gopkg.in/yaml.v2 v2.2.8
go: finding github.com/google/go-cmp v0.4.0
go: finding github.com/hashicorp/hcl v1.0.0
go: finding github.com/kr/text v0.1.0
go: finding github.com/jinzhu/inflection v1.0.0
go: finding github.com/go-playground/assert/v2 v2.0.1
go: finding github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0
go: finding github.com/json-iterator/go v1.1.9
go: finding github.com/go-playground/locales v0.12.1
go: finding github.com/leodido/go-urn v1.1.0
go: finding github.com/mattn/go-sqlite3 v1.11.0
go: finding github.com/kr/pty v1.1.1
go: finding github.com/gobuffalo/envy v1.7.1
go: finding gopkg.in/go-playground/validator.v8 v8.18.2
go: finding golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
go: finding github.com/stretchr/objx v0.1.1
go: finding golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9
go: finding github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742
go: finding github.com/golang/protobuf v1.3.3
go: finding golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
go: finding golang.org/x/sys v0.0.0-20200116001909-b77594299b42
go: finding golang.org/x/sys v0.0.0-20190515120540-06a5c4944438
go: finding github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421
go: finding github.com/stretchr/testify v1.4.0
go: finding github.com/ugorji/go/codec v1.1.7
go: finding github.com/lib/pq v1.5.2
go: finding github.com/denisenkom/go-mssqldb v0.0.0-20190515213511-eb9f6a1743f3
go: finding github.com/google/gofuzz v1.0.0
go: finding github.com/leodido/go-urn v1.2.0
go: finding gopkg.in/go-playground/assert.v1 v1.2.1
go: finding github.com/ugorji/go v1.1.7
go: finding github.com/spf13/pflag v1.0.3
go: finding github.com/json-iterator/go v1.1.7
go: finding golang.org/x/text v0.3.0
go: finding gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405
go: finding golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a
go: finding golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543
go: finding github.com/mattn/go-isatty v0.0.9
go: finding github.com/coreos/etcd v3.3.10+incompatible
go: finding github.com/rogpeppe/go-internal v1.3.2
go: finding golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a
go: finding golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e
go: finding golang.org/x/net v0.0.0-20190620200207-3b0461eec859
go: finding golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7
go: finding golang.org/x/sync v0.0.0-20190423024810-112230192c58
go: finding google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967
go: finding golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c
go: finding cloud.google.com/go v0.37.4
go: finding golang.org/x/tools v0.0.0-20190312170243-e65039ee4138
go: finding golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6
go: finding golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2
go: finding golang.org/x/net v0.0.0-20190311183353-d8887717615a
go: finding github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c
go: finding github.com/golang/mock v1.2.0
go: finding golang.org/x/time v0.0.0-20181108054448-85acf8d2951c
go: finding golang.org/x/exp v0.0.0-20190121172915-509febef88a4
go: finding honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a
go: finding github.com/google/martian v2.1.0+incompatible
go: finding google.golang.org/grpc v1.19.0
go: finding go.opencensus.io v0.20.1
go: finding golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f
go: finding github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57
go: finding github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024
go: finding google.golang.org/api v0.3.1
go: finding github.com/google/go-cmp v0.2.0
go: finding golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421
go: finding github.com/googleapis/gax-go/v2 v2.0.4
go: finding github.com/openzipkin/zipkin-go v0.1.6
go: finding google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107
go: finding honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099
go: finding github.com/golang/mock v1.1.1
go: finding github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
go: finding golang.org/x/net v0.0.0-20180826012351-8a410e7b638d
go: finding github.com/gogo/protobuf v1.2.0
go: finding github.com/Shopify/toxiproxy v2.1.4+incompatible
go: finding golang.org/x/sys v0.0.0-20180830151530-49385e6e1522
go: finding golang.org/x/net v0.0.0-20181114220301-adae6a3d119a
go: finding google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8
go: finding github.com/hashicorp/golang-lru v0.5.0
go: finding cloud.google.com/go v0.34.0
go: finding golang.org/x/tools v0.0.0-20190114222345-bf090417da8b
go: finding golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3
go: finding github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21
go: finding github.com/eapache/go-resiliency v1.1.0
go: finding cloud.google.com/go v0.26.0
go: finding github.com/eapache/queue v1.1.0
go: finding github.com/Shopify/sarama v1.19.0
go: finding github.com/onsi/ginkgo v1.7.0
go: finding github.com/gorilla/mux v1.6.2
go: finding golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f
go: finding github.com/golang/protobuf v1.4.0-rc.2
go: finding github.com/gorilla/context v1.1.1
go: finding github.com/pierrec/lz4 v2.0.5+incompatible
go: finding google.golang.org/appengine v1.4.0
go: finding golang.org/x/sync v0.0.0-20181108010431-42b317875d0f
go: finding golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e
go: finding github.com/onsi/gomega v1.4.3
go: finding google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60
go: finding github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db
go: finding github.com/apache/thrift v0.12.0
go: finding github.com/client9/misspell v0.3.4
go: finding golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b
go: finding golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be
go: finding google.golang.org/appengine v1.1.0
go: finding gopkg.in/fsnotify.v1 v1.4.7
go: finding google.golang.org/grpc v1.17.0
go: finding github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a
go: finding golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52
go: finding honnef.co/go/tools v0.0.0-20180728063816-88497007e858
go: finding github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208
go: finding github.com/onsi/ginkgo v1.6.0
go: finding golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e
go: finding github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829
go: finding gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7
go: finding github.com/hpcloud/tail v1.0.0
go: finding google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19
go: finding google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64
go: finding github.com/golang/protobuf v1.4.0-rc.1
go: finding github.com/kisielk/gotool v1.0.0
go: finding golang.org/x/net v0.0.0-20180906233101-161cd47e91fd
go: finding google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd
go: finding github.com/google/go-cmp v0.3.0
go: finding github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973
go: finding github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1
go: finding github.com/prometheus/common v0.2.0
go: finding github.com/google/go-cmp v0.3.1
go: finding github.com/gogo/protobuf v1.1.1
go: finding github.com/sirupsen/logrus v1.2.0
go: finding golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3
go: finding golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33
go: finding github.com/go-kit/kit v0.8.0
go: finding gopkg.in/alecthomas/kingpin.v2 v2.2.6
go: finding github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f
go: finding github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910
go: finding github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc
go: finding golang.org/x/crypto v0.0.0-20180904163835-0709b304e793
go: finding github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223
go: finding golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5
go: finding golang.org/x/net v0.0.0-20180724234803-3673e40ba225
go: finding github.com/prometheus/client_golang v0.9.1
go: finding github.com/go-logfmt/logfmt v0.3.0
go: finding github.com/go-stack/stack v1.8.0
go: finding github.com/matttproud/golang_protobuf_extensions v1.0.1
go: finding github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d
go: finding github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515
go: finding github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf
go: finding github.com/julienschmidt/httprouter v1.2.0
go: finding golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961
go: finding golang.org/x/net v0.0.0-20190213061140-3a22650c66bd
go: finding golang.org/x/tools v0.0.0-20190226205152-f727befe758c
go: downloading github.com/robfig/cron v0.0.0-20180505203441-b41be1df6967
go: downloading github.com/gotify/plugin-api v1.0.0
go: extracting github.com/gotify/plugin-api v1.0.0
go: downloading github.com/gin-gonic/gin v1.6.3
go: extracting github.com/robfig/cron v0.0.0-20180505203441-b41be1df6967
go: extracting github.com/gin-gonic/gin v1.6.3
go: downloading github.com/gin-contrib/sse v0.1.0
go: downloading github.com/ugorji/go v1.1.7
go: downloading github.com/golang/protobuf v1.4.1
go: downloading github.com/mattn/go-isatty v0.0.12
go: downloading github.com/go-playground/validator/v10 v10.2.0
go: downloading gopkg.in/yaml.v2 v2.2.8
go: extracting github.com/gin-contrib/sse v0.1.0
go: extracting github.com/mattn/go-isatty v0.0.12
go: downloading golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3
go: extracting gopkg.in/yaml.v2 v2.2.8
go: extracting github.com/ugorji/go v1.1.7
go: downloading github.com/ugorji/go/codec v1.1.7
go: extracting github.com/go-playground/validator/v10 v10.2.0
go: downloading github.com/go-playground/universal-translator v0.17.0
go: downloading github.com/leodido/go-urn v1.2.0
go: extracting github.com/golang/protobuf v1.4.1
go: downloading google.golang.org/protobuf v1.22.0
go: extracting github.com/go-playground/universal-translator v0.17.0
go: downloading github.com/go-playground/locales v0.13.0
go: extracting github.com/ugorji/go/codec v1.1.7
go: extracting github.com/leodido/go-urn v1.2.0
go: extracting golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3
go: extracting google.golang.org/protobuf v1.22.0
go: extracting github.com/go-playground/locales v0.13.0

Nothing gets built:

 docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
ppacher commented 4 years ago

Hey @siredwin, that command builds your plugin binary in a docker container and not a docker image. You should find a yourplugin-amd64.so in your working directory after that command. Also note that docker ps only lists running containers, if you want to see available images you'll need to run docker images. If you want to see stopped containers as well then docker ps -a is the way to go (though, the build command contains --rm so it will remove the exited container immediately).

siredwin commented 4 years ago

Thanks for that. I expected to see running containers. Docker is still not my strong suit. Now I see exited containers, so I am close.

siredwin commented 4 years ago

Ok, I think I have done everything else right. But I can't shake these version errors, i.e.

./gotify-linux-amd64
Starting Gotify version 2.0.0@2019-03-01-22:25:25
panic: error while loading plugin main.so: plugin.Open("data/plugins/main"): plugin was built with a different version of package github.com/gin-contrib/sse

goroutine 1 [running]:
github.com/gotify/server/router.Create(0xc000252640, 0xc000092240, 0xc00015c000, 0xe, 0xc00002a638)
    /proj/router/router.go:46 +0x3038
main.main()
    /proj/app.go:51 +0x382
jmattheis commented 4 years ago

Have you used our helper gomod-cap? https://gotify.net/docs/plugin-deploy Is your plugin available somewhere, that we can debug on the actual code?

siredwin commented 4 years ago

I am currently still experimenting with the examples in
https://github.com/gotify/server/tree/master/plugin/example. I have used gomod-cap and even borrowed the Makefile inside the plugin. I will try this again later and if it fails, I will opt to build from source instead.

eternal-flame-AD commented 4 years ago

Yeah the dependency issues for gin also happened to me back then. I remember at that time there was some problems with the gomod file in the gin project so go can't resolve to the same version of gin when we are building it.

siredwin commented 4 years ago

Perfect, all plugins are working fine when I build from source. I just need some clarifications:

Thanks again for this great service.

eternal-flame-AD commented 4 years ago

does packr get called inside the ui folder?

Uhh, yeah? Certainly we use that for packing the assets for the WebUI so thats used in the UI package.

On plugin features, it says One plugin instance per user. What does that mean?

That means NewGotifyPluginInstance will be called for each user that exist in the server. That's to explain that every user will have its own "plugin instance" to interact with.

siredwin commented 4 years ago

Thanks, I just needed to verify that I could have 100 plugins and I would be ok.