Skip to content
This repository has been archived by the owner on May 18, 2021. It is now read-only.

sgh-eltern/elternverteiler

Repository files navigation

Elternverteiler

Development

  • Create the database cluster if it does not exist yet.

    See brew info postgresql on how to start the database server.

    $ initdb -D /usr/local/var/postgres-10
  • Create the dev database

    $ createdb elternverteiler_dev
  • Configure the DB URI

    $ export DB=postgres://localhost/elternverteiler_dev
  • Migrate the database

    $ bundle exec rake db:migrate
  • Run the web app

    $ rerun -i 'spec/*' bundle exec rackup
  • Run Jobs Manually

    We use --worker-count 2 so that we do not overload the eMail servers. mailtrap.io at least does not accept more than 2/sec.

    $ que --log-level debug --queue mailer --worker-count 2 ./config/que.rb

Test

$ dropdb elternverteiler_test; createdb elternverteiler_test; rake db:migrate
bundle exec rake

If desired, restore a backup from within the app in order to get some real data.

Acceptance tests can be run in parallel:

$ rake parallel:rspec:acceptance

Troubleshooting

Use the sequel database monitor

$ bundle exec sequel $DB

Deployment

  • Backup needs a GCP bucket

    1. Create a service account (Account: uhlig-consulting.net, Project: SGH Elternbeirat)

    1. Download the credentials file. Export its contents as environment variable STORAGE_KEYFILE_JSON; the Ruby API will read it.

    2. Create a bucket sgh-elternbeirat-app-backup. No extra ACLs are necessary because the service account is already storage admin from the previous step.

  • Setup the database

    $ createdb elternverteiler
    $ export DB=postgres://localhost/elternverteiler
    $ bundle exec rake db:migrate
  • Create and authorize the SCP account

    The app uses SCP to up- and download the distribution list. Create an account that is capable of scp'ing to the server using a private key (the app does not do password authentiation). Configure the app using the following environment variables:

    export list_server_hostname=foo.example.com
    export list_server_username=bar
    export list_server_key_file=~/.ssh/id_rsa
  • Start the app and the background processor

    $ export puma_control_token=********
    $ export RACK_ENV=production
    $ gem install foreman
    $ foreman start
  • Show Puma stats

    $ pumactl --control-url unix://var/puma-ctl.sock --control-token "$puma_control_token" stats