meloalright / guora

🖖🏻 A self-hosted Quora like web application written in Go 基于 Golang 类似知乎的私有部署问答应用 包含问答、评论、点赞、管理后台等功能
MIT License
672 stars 103 forks source link

Record not found error #30

Open Ali-l opened 2 years ago

Ali-l commented 2 years ago

Hi I'd love to try this project but I keep getting a record not found error

IMG_20220816_111934.jpg

Would you know how to resolve this ?

meloalright commented 2 years ago

Can u show error logs on server?

Ali-l commented 2 years ago

Hi @meloalright ! Hope you are having a good week! Also wow, I did not expect anyone to respond! I will spin up the server and try it again I originally tried the docker version but that gave a few redis error and I did not know how to fix those. Let me try a without docker install and get you the logs.

Ali-l commented 2 years ago

Here is the first error I face right after setting up pre-requisites for guora:

Note: I am running Ubuntu 22.04.1

tiny@tiny-Aspire-5755G:~/gitStuff/guora$ sudo go run ./cmd/guora -init
go: downloading github.com/gin-gonic/gin v1.6.3
go: downloading github.com/spf13/viper v1.7.1
go: downloading golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de
go: downloading github.com/go-redis/redis/v8 v8.0.0-beta.7
go: downloading github.com/jinzhu/gorm v1.9.15
go: downloading github.com/dgrijalva/jwt-go v3.2.0+incompatible
go: downloading github.com/fsnotify/fsnotify v1.4.7
go: downloading github.com/hashicorp/hcl v1.0.0
go: downloading github.com/magiconair/properties v1.8.1
go: downloading github.com/mitchellh/mapstructure v1.1.2
go: downloading github.com/pelletier/go-toml v1.2.0
go: downloading github.com/spf13/afero v1.1.2
go: downloading github.com/spf13/cast v1.3.0
go: downloading github.com/spf13/jwalterweatherman v1.0.0
go: downloading github.com/spf13/pflag v1.0.3
go: downloading github.com/subosito/gotenv v1.2.0
go: downloading gopkg.in/ini.v1 v1.51.0
go: downloading gopkg.in/yaml.v2 v2.2.8
go: downloading github.com/gin-contrib/sse v0.1.0
go: downloading github.com/mattn/go-isatty v0.0.12
go: downloading github.com/go-sql-driver/mysql v1.5.0
go: downloading github.com/lib/pq v1.1.1
go: downloading github.com/mattn/go-sqlite3 v1.14.0
go: downloading github.com/jinzhu/inflection v1.0.0
go: downloading github.com/cespare/xxhash/v2 v2.1.1
go: downloading github.com/dgryski/go-rendezvous v0.0.0-20200624174652-8d2f3be8b2d9
go: downloading golang.org/x/exp v0.0.0-20200513190911-00229845015e
go: downloading github.com/cespare/xxhash v1.1.0
go: downloading golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd
go: downloading golang.org/x/text v0.3.2
go: downloading github.com/go-playground/validator/v10 v10.2.0
go: downloading github.com/golang/protobuf v1.4.2
go: downloading github.com/ugorji/go/codec v1.1.7
go: downloading go.opentelemetry.io/otel v0.7.0
go: downloading github.com/ugorji/go v1.1.7
go: downloading github.com/go-playground/universal-translator v0.17.0
go: downloading github.com/leodido/go-urn v1.2.0
go: downloading google.golang.org/protobuf v1.23.0
go: downloading google.golang.org/grpc v1.30.0
go: downloading github.com/go-playground/locales v0.13.0
# github.com/mattn/go-sqlite3
sqlite3-binding.c: In function ‘sqlite3SelectNew’:
sqlite3-binding.c:129019:10: warning: function may return address of local variable [-Wreturn-local-addr]
129019 |   return pNew;
       |          ^~~~
sqlite3-binding.c:128979:10: note: declared here
128979 |   Select standin;
       |          ^~~~~~~
Configuration.conf &{{sqlite3 ./guora.db} {localhost:6379  0} {gadisInCharge gadisAdmin@siska.co.id test123} :8080 en topsecret}

[2022-08-22 13:52:10] [info] removing callback `gorm:update_time_stamp` from /home/tiny/gitStuff/guora/internal/database/db.go:24  

[2022-08-22 13:52:10] [info] removing callback `gorm:update_time_stamp` from /home/tiny/gitStuff/guora/internal/database/db.go:25  
2022/08/22 13:52:10 [redis]: error dial tcp 127.0.0.1:6379: connect: connection refused
panic: failed to connect redis

goroutine 1 [running]:
github.com/meloalright/guora/internal/database.init.1()
        /home/tiny/gitStuff/guora/internal/database/redisdb.go:26 +0x1a5
exit status 2

At the bottom of log is redis error. This same error happens on docker deploy as well. I looked this up and setup both redis and sqlite3 manually. After setting up both I run the command sudo go run ./cmd/guora/ -init and Now I can access development site. But get the screenshot I gave on top and now the server msgs are these:

tiny@tiny-Aspire-5755G:~/gitStuff/guora$ sudo go run ./cmd/guora/ -init
# github.com/mattn/go-sqlite3
sqlite3-binding.c: In function ‘sqlite3SelectNew’:
sqlite3-binding.c:129019:10: warning: function may return address of local variable [-Wreturn-local-addr]
129019 |   return pNew;
       |          ^~~~
sqlite3-binding.c:128979:10: note: declared here
128979 |   Select standin;
       |          ^~~~~~~
Configuration.conf &{{sqlite3 ./guora.db} {localhost:6379  0} {gadisInCharge gadisAdmin@siska.co.id test123} :8080 en topsecret}

[2022-08-22 16:15:39] [info] removing callback `gorm:update_time_stamp` from /home/tiny/gitStuff/guora/internal/database/db.go:24  

[2022-08-22 16:15:39] [info] removing callback `gorm:update_time_stamp` from /home/tiny/gitStuff/guora/internal/database/db.go:25  
2022/08/22 16:15:39 [redis]: dbsize 0
redis flushdb.
db has the table user, so drop it.
db has the table profile, so drop it.
db has the table question, so drop it.
db has the table answer, so drop it.
db has the table comment, so drop it.
db has the table reply, so drop it.
db has the table supporter, so drop it.
already restarted.
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)

[GIN-debug] POST   /api/web/security/sign    --> github.com/meloalright/guora/internal/controller/web.SecuritySign (4 handlers)
[GIN-debug] POST   /api/web/security/login   --> github.com/meloalright/guora/internal/controller/web.SecurityLogin (4 handlers)
[GIN-debug] POST   /api/web/security/logout  --> github.com/meloalright/guora/internal/controller/web.SecurityLogout (4 handlers)
[GIN-debug] POST   /api/web/question         --> github.com/meloalright/guora/internal/controller/web.CreateQuestion (5 handlers)
[GIN-debug] POST   /api/web/answer           --> github.com/meloalright/guora/internal/controller/web.CreateAnswer (5 handlers)
[GIN-debug] POST   /api/web/answer/:id/supporters --> github.com/meloalright/guora/internal/controller/web.CreateSupporter (5 handlers)
[GIN-debug] DELETE /api/web/answer/:id/supporters --> github.com/meloalright/guora/internal/controller/web.DeleteSupporter (5 handlers)
[GIN-debug] POST   /api/web/comment          --> github.com/meloalright/guora/internal/controller/web.CreateComment (5 handlers)
[GIN-debug] POST   /api/web/reply            --> github.com/meloalright/guora/internal/controller/web.CreateReply (5 handlers)
[GIN-debug] POST   /api/web/file/avatar      --> github.com/meloalright/guora/internal/controller/web.FileAvatarResolve (5 handlers)
[GIN-debug] GET    /api/rest/user/:id        --> github.com/meloalright/guora/internal/controller/rest.GetUser (5 handlers)
[GIN-debug] GET    /api/rest/users           --> github.com/meloalright/guora/internal/controller/rest.GetUsers (5 handlers)
[GIN-debug] GET    /api/rest/users/counts    --> github.com/meloalright/guora/internal/controller/rest.GetUsersCounts (5 handlers)
[GIN-debug] PUT    /api/rest/user/:id        --> github.com/meloalright/guora/internal/controller/rest.UpdateUser (5 handlers)
[GIN-debug] DELETE /api/rest/user/:id        --> github.com/meloalright/guora/internal/controller/rest.DeleteUser (5 handlers)
[GIN-debug] GET    /api/rest/profile/:id     --> github.com/meloalright/guora/internal/controller/rest.GetProfile (5 handlers)
[GIN-debug] GET    /api/rest/profiles        --> github.com/meloalright/guora/internal/controller/rest.GetProfiles (5 handlers)
[GIN-debug] GET    /api/rest/profiles/counts --> github.com/meloalright/guora/internal/controller/rest.GetProfilesCounts (5 handlers)
[GIN-debug] PUT    /api/rest/profile/:id     --> github.com/meloalright/guora/internal/controller/rest.UpdateProfile (5 handlers)
[GIN-debug] DELETE /api/rest/profile/:id     --> github.com/meloalright/guora/internal/controller/rest.DeleteProfile (5 handlers)
[GIN-debug] GET    /api/rest/question/:id    --> github.com/meloalright/guora/internal/controller/rest.GetQuestion (5 handlers)
[GIN-debug] GET    /api/rest/questions       --> github.com/meloalright/guora/internal/controller/rest.GetQuestions (5 handlers)
[GIN-debug] GET    /api/rest/questions/counts --> github.com/meloalright/guora/internal/controller/rest.GetQuestionsCounts (5 handlers)
[GIN-debug] PUT    /api/rest/question/:id    --> github.com/meloalright/guora/internal/controller/rest.UpdateQuestion (5 handlers)
[GIN-debug] DELETE /api/rest/question/:id    --> github.com/meloalright/guora/internal/controller/rest.DeleteQuestion (5 handlers)
[GIN-debug] GET    /api/rest/answer/:id      --> github.com/meloalright/guora/internal/controller/rest.GetAnswer (5 handlers)
[GIN-debug] GET    /api/rest/answers         --> github.com/meloalright/guora/internal/controller/rest.GetAnswers (5 handlers)
[GIN-debug] GET    /api/rest/answers/counts  --> github.com/meloalright/guora/internal/controller/rest.GetAnswersCounts (5 handlers)
[GIN-debug] PUT    /api/rest/answer/:id      --> github.com/meloalright/guora/internal/controller/rest.UpdateAnswer (5 handlers)
[GIN-debug] DELETE /api/rest/answer/:id      --> github.com/meloalright/guora/internal/controller/rest.DeleteAnswer (5 handlers)
[GIN-debug] GET    /api/rest/comment/:id     --> github.com/meloalright/guora/internal/controller/rest.GetComment (5 handlers)
[GIN-debug] GET    /api/rest/comments        --> github.com/meloalright/guora/internal/controller/rest.GetComments (5 handlers)
[GIN-debug] GET    /api/rest/comments/counts --> github.com/meloalright/guora/internal/controller/rest.GetCommentsCounts (5 handlers)
[GIN-debug] PUT    /api/rest/comment/:id     --> github.com/meloalright/guora/internal/controller/rest.UpdateComment (5 handlers)
[GIN-debug] DELETE /api/rest/comment/:id     --> github.com/meloalright/guora/internal/controller/rest.DeleteComment (5 handlers)
[GIN-debug] GET    /api/rest/reply/:id       --> github.com/meloalright/guora/internal/controller/rest.GetReply (5 handlers)
[GIN-debug] GET    /api/rest/replies         --> github.com/meloalright/guora/internal/controller/rest.GetReplies (5 handlers)
[GIN-debug] GET    /api/rest/replies/counts  --> github.com/meloalright/guora/internal/controller/rest.GetRepliesCounts (5 handlers)
[GIN-debug] PUT    /api/rest/reply/:id       --> github.com/meloalright/guora/internal/controller/rest.UpdateReply (5 handlers)
[GIN-debug] DELETE /api/rest/reply/:id       --> github.com/meloalright/guora/internal/controller/rest.DeleteReply (5 handlers)
[GIN-debug] Loaded HTML Templates (8): 
        - answer.html
        - error.html
        - index.html
        - login.html
        - profile.html
        - question.html
        - 
        - admin.html

[GIN-debug] GET    /static/*filepath         --> github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1 (4 handlers)
[GIN-debug] HEAD   /static/*filepath         --> github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1 (4 handlers)
[GIN-debug] GET    /                         --> github.com/meloalright/guora/internal/view.Index (5 handlers)
[GIN-debug] GET    /profile                  --> github.com/meloalright/guora/internal/view.Profile (5 handlers)
[GIN-debug] GET    /question                 --> github.com/meloalright/guora/internal/view.Question (5 handlers)
[GIN-debug] GET    /answer                   --> github.com/meloalright/guora/internal/view.Answer (5 handlers)
[GIN-debug] GET    /admin                    --> github.com/meloalright/guora/internal/view.Admin (6 handlers)
[GIN-debug] GET    /login                    --> github.com/meloalright/guora/internal/view.Login (4 handlers)
[GIN-debug] GET    /error                    --> github.com/meloalright/guora/internal/view.Error (4 handlers)
[GIN-debug] Listening and serving HTTP on :8080
2022/08/22 16:15:45 latency: 762.014µs
[GIN] 2022/08/22 - 16:15:45 | 200 |      797.38µs |       127.0.0.1 | GET      "/login"
2022/08/22 16:15:58 record not found
2022/08/22 16:15:58 latency: 526.258µs
[GIN] 2022/08/22 - 16:15:58 | 200 |     541.412µs |       127.0.0.1 | POST     "/api/web/security/login"

I am not sure what step is missing - do let me know and thank you for making this project!

meloalright commented 2 years ago

I think u maybe logged with an email that did not exist.

Your admin configuration is based on the mail in this initial logs {gadisInCharge gadisAdmin@siska.co.id test123}

image

Maybe you should log in with the admin mail first,

and create another user count in admin page like this way.

image
meloalright commented 2 years ago

@Ali-l Hope you are having a good Wednesday!