zond / godip

A dippy adjudicator in Go.
GNU General Public License v3.0
27 stars 22 forks source link

router.go crashes on runtime: 116 #129

Closed PiecePaperCode closed 3 years ago

PiecePaperCode commented 3 years ago

navigating to localhost:8080/ produces this error

goroutine 23 [running]:
google.golang.org/appengine/internal.mustGetMetadata(0x9db988, 0x1f, 0x0, 0x0, 0xc000030100)
        /home/ubuntu/Documents/repo/github/godip/vendor/google.golang.org/appengine/internal/metadata.go:34 +0x14b
google.golang.org/appengine/internal.partitionlessAppID(0x9d655f, 0x15)
        /home/ubuntu/Documents/repo/github/godip/vendor/google.golang.org/appengine/internal/identity_vm.go:112 +0xa5
google.golang.org/appengine/internal.DefaultTicket.func1()
        /home/ubuntu/Documents/repo/github/godip/vendor/google.golang.org/appengine/internal/api.go:294 +0x9c
sync.(*Once).doSlow(0x1203778, 0x9f1180)
        /home/ubuntu/.go/go1.16beta1/src/sync/once.go:68 +0xec
sync.(*Once).Do(...)
        /home/ubuntu/.go/go1.16beta1/src/sync/once.go:59
google.golang.org/appengine/internal.DefaultTicket(0xc000300000, 0x9242e0)
        /home/ubuntu/Documents/repo/github/godip/vendor/google.golang.org/appengine/internal/api.go:289 +0x65
google.golang.org/appengine/internal.Call(0xa61220, 0xc000300000, 0x9d0ed2, 0xa, 0x9ce1d6, 0x5, 0xa5fdd0, 0xc0000340c0, 0xa5f350, 0xc00006c020, ...)
        /home/ubuntu/Documents/repo/github/godip/vendor/google.golang.org/appengine/internal/api.go:496 +0x914
google.golang.org/appengine/internal.(*context).flushLog(0xc0000ca8a0, 0x1, 0x0)
        /home/ubuntu/Documents/repo/github/godip/vendor/google.golang.org/appengine/internal/api.go:641 +0x47d
google.golang.org/appengine/internal.handleHTTP.func1(0xc0000967e0, 0xc0000ca8a0)
        /home/ubuntu/Documents/repo/github/godip/vendor/google.golang.org/appengine/internal/api.go:138 +0x58
created by google.golang.org/appengine/internal.handleHTTP
        /home/ubuntu/Documents/repo/github/godip/vendor/google.golang.org/appengine/internal/api.go:134 +0x3a5

bumping up the runtime to 116 resolves the issue app.yml

runtime: go116

handlers:
- url: /.*
  script: auto

Edit: Reloading the page works for the first time. Reloading it a second time it crashes

panic: Metadata fetch failed for 'instance/attributes/gae_project': Get "http://metadata/computeMetadata/v1/instance/attributes/gae_project": dial tcp: lookup metadata: no such host

goroutine 8 [running]:
google.golang.org/appengine/internal.mustGetMetadata(0x9db988, 0x1f, 0x0, 0x0, 0xc000030700)
        /home/ubuntu/Documents/repo/github/godip/vendor/google.golang.org/appengine/internal/metadata.go:34 +0x14b
google.golang.org/appengine/internal.partitionlessAppID(0x9d655f, 0x15)
        /home/ubuntu/Documents/repo/github/godip/vendor/google.golang.org/appengine/internal/identity_vm.go:112 +0xa5
google.golang.org/appengine/internal.DefaultTicket.func1()
        /home/ubuntu/Documents/repo/github/godip/vendor/google.golang.org/appengine/internal/api.go:294 +0x9c
sync.(*Once).doSlow(0x1203778, 0x9f1180)
        /home/ubuntu/.go/go1.16beta1/src/sync/once.go:68 +0xec
sync.(*Once).Do(...)
        /home/ubuntu/.go/go1.16beta1/src/sync/once.go:59
google.golang.org/appengine/internal.DefaultTicket(0xc000251c80, 0x9242e0)
        /home/ubuntu/Documents/repo/github/godip/vendor/google.golang.org/appengine/internal/api.go:289 +0x65
google.golang.org/appengine/internal.Call(0xa61220, 0xc000251c80, 0x9d0ed2, 0xa, 0x9ce1d6, 0x5, 0xa5fdd0, 0xc000034440, 0xa5f350, 0xc00006c6c0, ...)
        /home/ubuntu/Documents/repo/github/godip/vendor/google.golang.org/appengine/internal/api.go:496 +0x914
google.golang.org/appengine/internal.(*context).flushLog(0xc0000780c0, 0x1, 0x0)
        /home/ubuntu/Documents/repo/github/godip/vendor/google.golang.org/appengine/internal/api.go:641 +0x47d
google.golang.org/appengine/internal.handleHTTP.func1(0xc00002e2a0, 0xc0000780c0)
        /home/ubuntu/Documents/repo/github/godip/vendor/google.golang.org/appengine/internal/api.go:138 +0x58
created by google.golang.org/appengine/internal.handleHTTP
        /home/ubuntu/Documents/repo/github/godip/vendor/google.golang.org/appengine/internal/api.go:134 +0x3a5

Process finished with exit code 2
zond commented 3 years ago

It works for me:

zond@stinky:~/projects/godip/gae$ ~/google-cloud-sdk/bin/gcloud version
Google Cloud SDK 334.0.0
app-engine-go 1.9.71
app-engine-python 1.9.91
bq 2.0.66
cloud-datastore-emulator 2.1.0
core 2021.03.26
gsutil 4.60
zond@stinky:~/projects/godip/gae$ go version
go version go1.15.9 linux/amd64
zond@stinky:~/projects/godip/gae$ ~/google-cloud-sdk/bin/dev_appserver.py .
INFO     2021-04-05 13:34:32,100 devappserver2.py:289] Skipping SDK update check.
INFO     2021-04-05 13:34:32,196 api_server.py:282] Starting API server at: http://localhost:36743
WARNING  2021-04-05 13:34:32,200 instance_factory.py:151] go.mod found in parent directory. Move app.yaml to that directory and add the line "main: gae".
INFO     2021-04-05 13:34:32,200 instance_factory.py:178] Building with dependencies from go.mod.
INFO     2021-04-05 13:34:32,207 dispatcher.py:267] Starting module "default" running at: http://localhost:8080
INFO     2021-04-05 13:34:32,208 admin_server.py:150] Starting admin server at: http://localhost:8000
INFO     2021-04-05 13:34:35,040 instance.py:294] Instance PID: 24895
PiecePaperCode commented 3 years ago

There are no instruktions how to run your code except with appengine. but i dont want to dev on the cloud yet. i want it local. running with golang IDE produces the error above. bumping up the version runs fine for the first call and crashes in the second.

go run gae/router.go

gives me undefined :Phase

TimothyJones commented 3 years ago

It has been a while, but wouldn't go run gae/router.go only compile part of the package? You might have better luck with go run gae

zond commented 3 years ago

There are no instruktions how to run your code except with appengine. but i dont want to dev on the cloud yet. i want it local. running with golang IDE produces the error above. bumping up the version runs fine for the first call and crashes in the second.

go run gae/router.go

gives me undefined :Phase

I don't think it's possible to run the app like that - it's an App Engine app, and you run it with dev_appserver.py.

On the other hand, why would you want to run the App Engine app for the adjudicator library? Just include the library in whatever server you want to run?

zond commented 3 years ago

It has been a while, but wouldn't go run gae/router.go only compile part of the package? You might have better luck with go run gae

As I said - it's an App Engine app. Run it with dev_appserver.py. But why? It's just a library, and the app we are talking about is just a public adjudication service that already runs on http://godip-adjudication.appspot.com/

PiecePaperCode commented 3 years ago

then give exact instruktions witch dependencys i need on my system. i didnt know i had to install go cloud and run a python file to exec the lib. thats an assumtion you expect on a beginner go programmer. i would naturaly find the main go file an try to run that. the autogenerated documentation didnt help me ether as it just is a lib dump of your code bedder just look the code directly. i would love to see an example. how can i move units fight and observe the results. you give json get request in your readme. this is fine for people that look at your code as a black box. this even got suggested by the guy who initialy brought me here. he told me just dont care how the lib works.

zond commented 3 years ago

This project is mostly just a library. It's not super easy to use (Diplomacy rules are complicated), but it's fairly flexible and well tested.

It does include a super simple adjudication server that I run on the above linked host (using my own money, and don't make a dime off), but it only resolves game states that you POST it, and returns the new states. It doesn't do anything that you couldn't just as easily do with the code directly - but since it runs over HTTP/JSON you can use it from other languages than Go.

However, the included server is not the main purpose of this library (and I don't know of anyone actually that uses it) and therefore I've never invested in writing much docs or examples for it.

https://github.com/zond/diplicity is a game server. It includes (in the main README) instructions for how to run it.

However, it (like the tiny server included in this adjudicator lib) uses App Engine to run, and you will (as the README will explain) need to use the dev_appserver to run it locally.

"thats an assumtion you expect on a beginner go programmer"

I wouldn't necessarily expect a beginner Go coder to use this library.

zond commented 3 years ago

Also, for the record: Running an app with dev_appserver.py runs it locally, not in the cloud.