elct9620 / coscup2018-example-server

The Mobile Game Server prototype

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hime Server pipeline status coverage report

Requirement

  • Ruby 2.5.1
  • PostgreSQL

Development

For client development, we need to modify /etc/hosts to define the hostname.

127.0.0.1 api.hime.lcoal
127.0.0.1 hime.local

And run the server using port 3000 to ensure the client can access it.

Testing

Generate Google Play IAP Receipt

Generate RSA Public/Private Key

openssl genpkey -algorithm RSA -out spec/fixtures/files/payment/google_play/private.key -pkeyopt rsa_keygen_bits:2048
openssl rsa -pubout -outform der -in spec/fixtures/files/payment/google_play/private.key -out spec/fixtures/files/payment/google_play/public.der

How to save receipt signature

require 'openssl'

json = File.read(receipt_json_path)
key = OpenSSL::PKey::RSA.new(private_key)
sign = key.sign(OpenSSL::Digest::SHA1.new, json.gsub(/(\r\n|\r|\n)/, ''))
File.write(path, Base64.encode64(sign))

Release

Before release new version, please update config/initializers/version.rb and change it to latest server version.

TODO: Build Version should saved inside database and provide latest assets bundle for player.

Deployment

Server Environment

  • Centos7
  • Nginx with Passenger
  • Ruby 2.5.1
  • PostgreSQL

Environment Variables

TLD_LENGTH

The Rails default set it to 1, so the request.subdomain will return api if host is api.basaltic.tw But this project is using api.hime.basaltic.tw as hostname, we need set it to 2.

About

The Mobile Game Server prototype


Languages

Language:Ruby 93.0%Language:HTML 5.2%Language:JavaScript 1.1%Language:CSS 0.7%