27 March 2013

My own install of prose.io

Prose.io is an awesome tool for editing files hosted on Github using the Github API. Prose itself is entirely static, using Node and a couple other bits to connect to Github as its backend.

We will need two URL endpoints for this exercise, in my case:


A vague installation document exists on the prose.io site - but this was merely a starting point. The details in that document (at time of writing) have been merged into these install instructions.

Install Prose.io by forking the repo on Github and cloning to a directory on your server:

$ cd /srv/www
$ git clone git@github.com:mafrosis/prose.git prose.mafro.net

At this point it's a good idea to create another branch from the latest tag, so we can commit our modified files/config later:

$ git fetch --tags
$ git checkout -b v0.5.0 v0.5.0-mafro

Github Auth

Now we need to authenticate our application over at Github here.

Register a new OAuth app


Next we're supposed to install the Prose.io Gatekeeper app. Following the install instructions on Github and reading their code, it becomes apparent that it uses both a Coffescript Cakefile and deployment to Heroku. Unfortunately, I intended to use neither!

I grabbed the relevant files direct from the Github:

$ cd /srv/www/prose.mafro.net
$ wget https://raw.github.com/prose/gatekeeper/master/config.json
$ wget https://raw.github.com/prose/gatekeeper/master/package.json
$ wget https://raw.github.com/prose/gatekeeper/master/server.js
$ mkdir gatekeeper

I needed to edit the config.json file to add my Github application's client_id and client_secret. Which is easy enough.

Now I needed Node, which I installed from source:

$ wget http://nodejs.org/dist/v0.10.1/node-v0.10.1.tar.gz
$ tar xvf node-v0.10.1.tar.gz
$ cd node-v0.10.1
$ ./configure
$ make
$ sudo make install

Attempting to start the Gatekeeper with node server.js with led me to find I needed a package called express:

$ npm install express

Now the Gatekeeper app can be run via node like so:

$ cd /srv/www/prose.mafro.net/gatekeeper
$ node server.js

Tie it all together

Tell Prose where the Gatekeeper app is going to be found:

$ cd /srv/www/prose.mafro.net
$ cat _config.yml
auto: true
server: true
pygments: true
permalink: none
baseurl: ""
oauth_client_id: <github_app_client_id>
gatekeeper_url: http://prose-gatekeeper.mafro.net
- .gitignore
- gatekeeper


Running jekyll generates all the static files for Prose, and starts up a little webserver. The webserver is only for development - so just kill that right away. We want something a little more robust..

$ cd /srv/www/prose.mafro.net
$ jekyll
Configuration from /srv/www/prose.mafro.net/_config.yml
Auto-regenerating enabled: /srv/www/prose.mafro.net -/srv/www/prose.mafro.net/_site
[2013-03-27 05:49:07] regeneration: 1 files changed
[2013-03-27 05:49:07] INFO  WEBrick 1.3.1
[2013-03-27 05:49:07] INFO  ruby 1.8.7 (2010-08-16) [x86_64-linux]
[2013-03-27 05:49:07] INFO  WEBrick::HTTPServer#start: pid=25166 port=4000
[2013-03-27 05:49:08] regeneration: 1 files changed
[2013-03-27 05:49:08] regeneration: 1 files changed
[2013-03-27 05:49:09] regeneration: 1 files changed
[2013-03-27 05:49:09] regeneration: 1 files changed
[2013-03-27 05:49:10] regeneration: 1 files changed
[2013-03-27 05:49:10] regeneration: 1 files changed
[2013-03-27 05:49:11] regeneration: 1 files changed
^C[2013-03-27 05:57:18] INFO  going to shutdown ...
[2013-03-27 05:57:18] INFO  WEBrick::HTTPServer#start done.


Finally a little nginx setup to serve both prose and gatekeeper. I also added a basic auth to prevent the whole internets from using my new install :)

server {
    listen 80;
    server_name prose.mafro.net;
    root /var/www/prose.mafro.net/_site;
    index index.html;

    auth_basic 'ask and ye shall receive';
    auth_basic_user_file /etc/nginx/passwd.basic;

server {
    listen 80;
    server_name prose-gatekeeper.mafro.net;
    root /var/www/prose.mafro.net/gatekeeper;

    location / {
        proxy_redirect     off;
        proxy_pass_header  Server;


Right now the Gatekeeper Node app is running in a term (or not running at all). We can demonise arbitary applications easily with Supervisor.

An initial bit of setup:

$ cd /srv/www/prose.mafro.net
$ touch supervisor.conf
$ sudo aptitude install supervisor
$ sudo ln -s /srv/www/prose.mafro.net/supervisor.conf /etc/supervisor/conf.d/prose-gatekeeper.conf

Now put the following in your supervisor.conf file we just created, changing the paths as appropriate.

command=node server.js

Lastly inform Supervisor of your new config:

$ sudo supervisorctl update
prose-gatekeeper: added process group
$ sudo supervisorctl status
prose-gatekeeper                 RUNNING    pid 29423, uptime 0:00:03


Tagged in tekkers