GAE+Go1.12でEchoサーバーを立ち上げるためのサンプルです。 DataStoreへのアクセスはmercari/datastoreのboomを利用しています。
https://qiita.com/br_branch/items/a26480a05ecb97ac20b3
https://qiita.com/br_branch/items/1b63b2c1dd9b4ff3931e
- goenv 2.0.0beta11
- go v1.12.9
- Google Cloud SDK 253.0.0
- Redis local server 5.0.5
see https://redis.io/topics/quickstart
ターミナル3つ使ってそれぞれのエミュレーター / サーバーを立ち上げます。
$ redis-server
65146:C 07 Sep 2019 17:03:08.988 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
65146:C 07 Sep 2019 17:03:08.988 # Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=65146, just started
65146:C 07 Sep 2019 17:03:08.988 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
65146:M 07 Sep 2019 17:03:08.989 * Increased maximum number of open files to 10032 (it was originally set to 4864).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 5.0.5 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 65146
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
65146:M 07 Sep 2019 17:03:08.990 # Server initialized
65146:M 07 Sep 2019 17:03:08.990 * Ready to accept connections
^C65146:signal-handler (1567843408) Received SIGINT scheduling shutdown...
65146:M 07 Sep 2019 17:03:28.793 # User requested shutdown...
65146:M 07 Sep 2019 17:03:28.793 * Saving the final RDB snapshot before exiting.
$ gcloud beta emulators datastore start --host-port localhost:8059 --project test-project
$ cd ./src
$ env DATASTORE_EMULATOR_HOST=localhost:8059 DATASTORE_PROJECT_ID=test-project REDIS_ADDR=localhost:6379 go run main.go
app.yamlにある環境変数をそれぞれ設定ください。
PROJECT_ID
: ご自身のGCP Project IDREDIS_ADDR
: RedisのエンドポイントREDIS_PASS
: Redisのパスワード
gcloud app deploy
gcloud app deploy --project PROJECT_ID --version VERSION_ID --no-promote