Thursday, September 19, 2013

Add Google Coder to my PiBang

Google Coder is a new Node.JS-based application to help kids create web pages that include HTML, JavaScript and CSS. Google releases it as a new distribution that based on wheezy Raspbian.

I don't want to re-invent the wheel, thus I try to add Google Coder to my current PiBang.
~ # cd ~git.d
~/git.d # git clone git://github.com/googlecreativelab/coder
~/git.d # cd coder/coder-base
~/git.d # npm install

Then I modified the coder/coder-base/config.js to make ensure it starts on the TCP ports that I want. See below:
exports.listenIP = null; //Defaults to *
exports.listenPort = '9181'; //the SSL port things run on
exports.httpListenPort = '9180'; //this will all be redirected to SSL
exports.cacheApps = true;
exports.httpVisiblePort = '9080'; //forwarded http port the user sees
exports.httpsVisiblePort = '9443'; //forwarded https port the user sees

Lastly, I can start it instantly with the command below:
~/git.d # cd coder/coder-base
~/git.d # npm start
Then, from another computer, I launched the browser and browse to my RPi at the URL https://192.168.1.[my-RPi-IP]:9181/ and create the password (for 'pi'). After that I just login again the newly created password and below is the screenshot:
Google Coder on PiBang 
P/S: If you want to configure the node.js to start automatic in PiBang (which using systemd instead of sysV), you will need the below. Below is my sample at /etc/systemd/system/coder.service
[Unit]
Description=Google Coder
After=network.target

[Service]
Type=simple
WorkingDirectory=/root/git.d/coder/coder-base
ExecStart=/usr/local/bin/npm start
Restart=always

[Install]
WantedBy=multi-user.target