Skip to content

TM020 CPO roughnums

Dorai Sitaram edited this page Jan 23, 2015 · 4 revisions

Setting up a Heroku instance of CPO with roughnums

The roughnum branch of CPO

I’ve added a roughnum branch to github.com/brownplt/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 brownplt/pyret-lang’s roughnum rather than the (default) master branch.

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

The process

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

Login to heroku:

heroku login

Get the roughnum version of CPO as follows:

git clone https://github.com/brownplt/code.pyret.org
cd code.pyret.org
git checkout roughnum

Heroku apps are named globally; so you’ll have to choose a distinctive name for your app. In the following, I’ll use rough-pyret: Substitute it with whatever name you are able to use.

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

heroku apps:destroy --confirm rough-pyret

Now, create the app:

heroku create rough-pyret

Now set the environment variables for the app:

heroku config:set \
  GOOGLE‗CLIENT‗ID="" \
  GOOGLE‗CLIENT‗SECRET="" \
  GOOGLE‗API‗KEY="" \
  BASE‗URL="https://rough-pyret.herokuapp.com" \
  SESSION‗SECRET="not-so-secret" \
  REDISCLOUD‗URL="" \
  USE‗STANDALONE‗PYRET="true" \
  PYRET‗RELEASE‗BASE="https://rough-pyret.herokuapp.com/js" \
  CURRENT‗PYRET‗RELEASE="" \
  PORT=5000 \
  NODE‗ENV=development

Now push your CPO branch into heroku:

git push heroku roughnum: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://rough-pyret.herokuapp.com/editor, which you can browse to. The web repl offered here should let you test out the roughnum branch of pyret-lang.

The cpo-heroku script

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

cpo-heroku rough-pyret

does what I’ve desribed 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.