spicybackend / skirmish

Enjoy your games and forget the hassle of managing tournaments

Home Page:https://skirmish.online

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Skirmish

Skirmish logo

CircleCI dependencies Using Amber framework

Getting Started

These instructions will get a copy of this project running on your machine for development and testing purposes.

Prerequisites

This project requires Crystal The version of Crystal used is defined inside .crystal-version. I'd recommend using crenv to install the current version of Crystal, which is as simple as the following command inside the project folder.

crenv install

There are also some other dependencies required for some extensions of Crystal and Amber, as well as PostgresQL.

For Ubuntu
sudo apt install -y postgresql libssl-dev libxml2-dev libyaml-dev libgmp-dev libreadline-dev libevent-dev libsqlite3-dev
For OSX
brew tap amberframework/amber
brew install amber
brew install postgresql

Postgres

Unless you've used Postgres before, or know your way around configuring it already, you'll probably want to follow this quick guide to setting up users for development.

Postgres Quickstart

User creation

For Ubuntu
# start a session as the postgres user
sudo su - postgres;

# create a user named postgres if it doesn't already exist
create user skirmish;

# then grant it super user access
alter user skirmish with superuser;

# optionally create a user to login to postgres yourself
create user <username> --pwprompt;

# exit the session as postgres
exit
For OSX
# start a session as the postgres user
psql postgres

# create a user named postgres if it doesn't already exist
create user skirmish;

# then grant it super user access
alter user skirmish with superuser;

# exit the session as postgres
exit

Authentication configuration

To change the authentication with postgres to use a simple password 'trust' authentication method, we'll need to edit the pg_hba.conf file.

For Ubuntu
sudo vim /etc/postgresql/9.5/main/pg_hba.conf
For OSX
vim /usr/local/var/postgres/pg_hba.conf

Replace md5 with trust on the lines for local connections

# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust

Restarting the Postgres service

And finally, ensure the settings for postgres have been applied by restarting the service

For Ubuntu
sudo service postgresql restart
For OSX
brew services restart postgresql

Development

To start your Amber server (Both Linux and Mac):

# update the development environment settings to your liking
cp config/environments/development.yml.example config/environments/development.yml

shards install                    # install dependencies
shards build                      # build executable binaries
crystal ./src/sam.cr -- db:setup  # create the database and bring it up to speed
bin/amber db seed                 # optionally seed the database with some mock data
bin/amber watch                   # start the server and watch for file changes

Now you can visit http://localhost:3000/ from your browser.

Tests

To run the test suite:

crystal spec

Possible Installation Issues

Amber server.bind_ssl

Some setups are hitting undefined bind_ssl method errors within Amber itself. The good news is that we don't actually need it.

Error in src/skirmish.cr:3: instantiating 'Amber::Server:Class#start()'

Amber::Server.start
              ^~~~~

in lib/amber/src/amber/server/server.cr:17: instantiating 'Amber::Server#run()'

      instance.run
               ^~~

in lib/amber/src/amber/server/server.cr:50: instantiating 'start()'

        start
        ^~~~~

in lib/amber/src/amber/server/server.cr:62: undefined method 'bind_ssl' for HTTP::Server

        server.bind_ssl Amber.settings.host, Amber.settings.port, ssl_config, settings.port_reuse
               ^~~~~~~~

Rerun with --error-trace to show a complete error trace.

Resolution

Open the breaking file /skirmish/lib/amber/src/amber/server/server.cr

And comment out lines 60-63 and 65

#  if ssl_enabled?
#    ssl_config = Amber::SSL.new(settings.ssl_key_file.not_nil!, settings.ssl_cert_file.not_nil!).generate_tls
#    server.bind_ssl Amber.settings.host, Amber.settings.port, ssl_config, settings.port_reuse
#  else
    server.bind_tcp Amber.settings.host, Amber.settings.port, settings.port_reuse
#  end

Contributing

  1. Fork it
  2. Create your feature branch ( git checkout -b my-new-feature )
  3. Commit your changes ( git commit -am 'Add some feature' )
  4. Push to the branch ( git push origin my-new-feature )
  5. Create a new Pull Request

Contributors

About

Enjoy your games and forget the hassle of managing tournaments

https://skirmish.online


Languages

Language:Crystal 79.7%Language:TSQL 9.0%Language:CSS 7.1%Language:JavaScript 3.5%Language:HTML 0.7%Language:Dockerfile 0.0%