Running Shopify’s Dashing on a Raspberry Pi

Dashing on a headless Raspberry Pi

Rough draft for reminder purposes

Micronext wireless USB adaptor, followed these instructions.

Installed gem, installed ruby, installed nodejs.

Followed the dashing homepage instructions to install dashing.

Added init.d script to auto start dashing in production mode on port 5000.

Followed these instructions to autostart Chrome in kiosk mode on the pi. What I did differently was to use Hexxeh’s Chrome instead of chromium-browser as chromium-browser hogged memory and would crash badly. I also made the custom-x-start script dependant on the dashing startup script to give dashing a chance to start before Chrome tried to load it. Dashing takes about 30 seconds to get started.

#!/bin/bash

### BEGIN INIT INFO
# Provides:        dasher_start
# Required-Start:  $network $syslog
# Required-Stop:
# Default-Start:   2 3 4 5
# Default-Stop:
# Short-Description: Starts up the dasher server
### END INIT INFO

set -e

# Feel free to change any of the following variables for your app:
TIMEOUT=${TIMEOUT-60}
APP_ROOT=/home/pi/dashboard/example_dashboard
PID=$APP_ROOT/tmp/pids/thin.5000.pid
CMD="cd $APP_ROOT; dashing start -s1 -d -p 5000 -e production -P $PID "
AS_USER=pi
set -u

OLD_PIN="$PID.oldbin"

sig () {
  test -s "$PID" && kill -$1 `cat $PID`
}

oldsig () {
  test -s $OLD_PIN && kill -$1 `cat $OLD_PIN`
}

run () {
  if [ "$(id -un)" = "$AS_USER" ]; then
    eval $1
  else
    su -c "$1" - $AS_USER
  fi
}

case "$1" in
    start)
      sig 0 && echo >&2 "Already running" && exit 0
      run "$CMD"
      ;;
    stop)
      sig QUIT && exit 0
      echo >&2 "Not running"
      ;;
    restart)
      sig HUP && echo reloaded OK && exit 0
      echo >&2 "Couldn't reload, starting '$CMD' instead"
      run "$CMD"
      ;;
    *) echo "usage: $0 start|stop|restart" >&2
       exit 1
       ;;
esac

As the startx script is running as root, I needed to add “–user-data-dir=/home/pi/chromium” to the path call as suggested by the error Chrome returns when trying to run as root.

Chromium-browser barely worked but Hexxeh’s Chrome uses about 50-55% memory (as reported by top) and the CPU seems to bounce around from 1-75%. Dashing’s sample page is rather JS heavy and over time eats up all available memory. It’s took about 4 hours before Chrome would render the sad face of a closed tab. As such I added a JS refresh to the top of dashing’s layout page so it reloads every 30 minutes. It makes for an unsightly white screen for 5 seconds every 30 minutes but it keeps the page from crashing.

How the hardware looks

The hardware as it stands

This entry was posted in Nothing. Bookmark the permalink.

8 Responses to Running Shopify’s Dashing on a Raspberry Pi

  1. We’re using the same workaround with refreshing our dashboards every hour @ Shopify. I’ve been meaning to look deeper into memory issues, especially since these dashboards are usually running on memory starved devices.

  2. Jay says:

    Awesome! Trying to do the same but getting a segmentation fault when I hit the web server. Wondering if it’s a library thing. Can I ask what version of ruby you’re running? Are you using rvm?

  3. scubes13 says:

    Could you share how you setup your init.d script for dashing?

  4. Mark says:

    What was the init.d script that you used to auto-start dashing? I’ve been arguing with it myself, and haven’t got it working yet.

  5. scott says:

    I’ve added the init.d script I used up above, it’s just hacked from a Unicorn restart script I had so probably not ideal but works fine.

  6. scott says:

    @jay Used ruby 1.9.3 as it was current at the time and no, I didn’t use RVM or rbenv as it’s a one shot machine, it can barely cope with this as it is so it seemed like a waste of time. I’d love to try the 512Mb machine and see how that goes.

  7. Gilbert says:

    Thanks for the init script! I just started playing around with Dashing this week and got a Chef widget to display our pod’s clusters from a databag. Can easily be modified to show other Chef details.

    Currently using Chromecast to send the page but thought of a Raspberry Pi for just displaying the page itself, not dashing+thin. After reading this, think I’ll pick one up or something similar. Ideally something I can use openconnect with to log onto our VPN.

    • scott says:

      My pleasure. I’m very keen to try the 512Mb Rpi, I think that would work nicely and make for a self contained silent dashboard.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>