How to deploy rqlite by docker-compose?

182 views
Skip to first unread message

Phuc Truong

unread,
Apr 1, 2021, 12:15:05 AM4/1/21
to rqlite
Hi, I am having a problem with deploy in docker-compose. When I tried to create a new table, my server code returned an error like:

{"level":"error","ts":1617250403.0066378,"caller":"generator/generator_db.go:25","msg":"tried all peers unsuccessfully. here are the results:\n   peer #0: http://0.0.0.0:4001/db/execute?timings&level=weak&transaction failed due to Post \"http://0.0.0.0:4001/db/execute?timings&level=weak&transaction\": dial tcp 0.0.0.0:4001: connect: connection refused\n","stacktrace":"id-generator/generator.(*GeneratorDB).CreateTableIfNotExist\n\t/opt/app/generator/generator_db.go:25\nid-generator/generator.(*GeneratorAPI).tap\n\t/opt/app/generator/generator_api.go:39\ngithub.com/gin-gonic/gin.(*Context).Next\n\t/go/pkg/mod/github.com/gin-gonic/g...@v1.6.3/context.go:161\ngithub.com/gin-gonic/gin.RecoveryWithWriter.func1\n\t/go/pkg/mod/github.com/gin-gonic/g...@v1.6.3/recovery.go:83\ngithub.com/gin-gonic/gin.(*Context).Next\n\t/go/pkg/mod/github.com/gin-gonic/g...@v1.6.3/context.go:161\ngithub.com/gin-gonic/gin.LoggerWithConfig.func1\n\t/go/pkg/mod/github.com/gin-gonic/g...@v1.6.3/logger.go:241\ngithub.com/gin-gonic/gin.(*Context).Next\n\t/go/pkg/mod/github.com/gin-gonic/g...@v1.6.3/context.go:161\ngithub.com/gin-gonic/gin.(*Engine).handleHTTPRequest\n\t/go/pkg/mod/github.com/gin-gonic/g...@v1.6.3/gin.go:409\ngithub.com/gin-gonic/gin.(*Engine).ServeHTTP\n\t/go/pkg/mod/github.com/gin-gonic/g...@v1.6.3/gin.go:367\nnet/http.serverHandler.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2843\nnet/http.(*conn).serve\n\t/usr/local/go/src/net/http/server.go:1925"}

Here is my docker-compose.yaml and here is my service code that use the connection. I am using gorqlite as a dbal. 

Please help me or point me what I did wrong. 

Many thanks!




Philip O'Toole

unread,
Apr 1, 2021, 8:24:12 AM4/1/21
to rql...@googlegroups.com
I don't know if this is the issue, but http://0.0.0.0 is not a valid address for HTTP requests. If you're going to tell rqlite to listen to 0.0.0.0 (via -http-addr), which is fine to do, then you must set -http-adv-addr so other nodes know what address to use to contact it on. Same for -rqlite-addr.

--
You received this message because you are subscribed to the Google Groups "rqlite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rqlite+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rqlite/d777b276-977a-4f8b-bc20-c81cffd07e11n%40googlegroups.com.

Phuc Truong

unread,
Apr 1, 2021, 11:17:34 PM4/1/21
to rqlite
Yes, I knew it, but I did not set the http://0.0.0.0 to anywhere. You can check the code, they are all http://vinlab-rqlite:4001, but it still appear in the log??!?!

From the container of vinlab-idgen, I've tried to connect through the curl like: 

curl -XPOST 'http://vinlab-rqlite:4001/db/execute?pretty&timings' -H "Content-Type: application/json" -d '[ "CREATE TABLE foo (id INTEGER NOT NULL PRIMARY KEY, name TEXT, age INTEGER)" ]'

and it works!

I think the problem comes from the gorqlite client!


Vào lúc 19:24:12 UTC+7 ngày Thứ Năm, 1 tháng 4, 2021, Philip O'Toole đã viết:
Reply all
Reply to author
Forward
0 new messages