Skip to content
sorawee edited this page Mar 29, 2016 · 5 revisions

Setting up Heroku instances of CPO with Spyret and Pyret-with-complex-roughnums

The relevant branches

I’ve added branches spyret and cpyret to github.com/ds26gte/code.pyret.org (aka CPO) that should make this process easy. The changes from the master branch consist in:

  1. the package.json file, which changes the dependencies → pyret-lang field to point to ds26gte/pyret-lang’s dual-lang rather than the (default) master branch.

  2. a shell script cpo-heroku that automates most of what’s here.

cpyret gives a repl that’s regular Pyret enhanced with complex numbers (both gaussian and rough).

spyret gives a (We)Scheme repl.

Both of them talk to the dual-lang branch of ds26gte/pyret-lang. (pyret-lang is meant to be dialect-diagnostic: it should, without modification, be capable of supporting both regular Pyret and Scheme versions of CPO.)

Note
The ds26gte/pyret-lang’s dual-lang branch should be up-to-date and stable. Remember to run make new-bootstrap and to push the resultant build/phase0/pyret-js.
Note
Why dual-lang rather than horizon? The pyret-lang#dual-lang branch contains features that can recognize the language of the CPO repl — i.e., regular Pyret or Scheme — and behave accordingly. It also implements complex numbers that are needed by Scheme and could also be used by Pyret.

The process

Ensure you’ve already installed the heroku toolbelt (available from http://toolbelt.heroku.com).

Login to heroku:

heroku login

Get the spyret version of CPO as follows:

git clone https://github.com/ds26gte/code.pyret.org
cd code.pyret.org
git checkout spyret

Heroku apps are named globally; so you’ll have to choose a distinctive name for your app. In the following, I’ll use spyret: Substitute it with whatever name you are able to use. (It’s a lucky coincidence that spyret also happens to be the name of our CPO branch. You’re usually not so lucky.)

If you’ve already created spyret and wish to re-create it from scratch, run

heroku apps:destroy --confirm spyret

Now, create the app:

heroku create spyret

Now set the environment variables for the app:

heroku config:set \
  GOOGLE_CLIENT_ID="" \
  GOOGLE_CLIENT_SECRET="" \
  GOOGLE_API_KEY="" \
  BASE_URL="https://spyret.herokuapp.com" \
  SESSION_SECRET="not-so-secret" \
  REDISCLOUD_URL="" \
  USE_STANDALONE_PYRET="true" \
  PYRET_RELEASE_BASE="https://spyret.herokuapp.com/js" \
  CURRENT_PYRET_RELEASE="" \
  PORT=5000 \
  NODE_ENV=development

Now push your CPO branch into heroku:

git push heroku spyret:master

You can monitor that things are going OK by running

heroku logs --tail

in another window.

Scale the app:

heroku ps:scale web=1

If all goes well, this will create a running app at https://spyret.herokuapp.com/editor, which you can browse to.

The cpo-heroku script

The cpo-heroku script takes a single argument, the name chosen for the app. E.g.,

cpo-heroku spyret

does what I’ve described above, up to the scaling. It also takes care to erase any previous apps of the same name, provided they belong to you. You’ll still have to pick a usable name that isn’t already taken.

Pyret with complex roughnums

To try this, switch to the cpyret branch, and then call cpo-heroku with a suitable Heroku app name (e.g., cpyret):

git checkout cpyret
cpo-heroku cpyret